dev-cpp-users Mailing List for Dev-C++ (Page 100)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
| 2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
| 2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
| 2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
| 2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
| 2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
| 2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
| 2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
| 2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
| 2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
| 2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
| 2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
| 2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
| 2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
| 2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
| 2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Reid T. <rei...@at...> - 2005-11-10 04:08:49
|
Eric Edwards wrote: > Scott, > > Try out this url: > > http://www.cprogramming.com/tutorial/cfileio.html > > Eric > > =20 > > -----Original Message----- > *From:* dev...@li...=20 > [mailto:dev...@li...] *On Behalf Of *Scott > *Sent:* Wednesday, November 09, 2005 6:38 PM > *To:* dev...@li... > *Subject:* [Dev-C++] Ascii and Binary help > > =20 > > Okay this is a hard question to phrase.... > > I'm trying to do a simple command line > > utility in DevC, to write to a file..... > > =20 > > Now i have no problems writing > > "Hello World" to the screen or text file. > > =20 > > But how do i write a binary file? > > for example... > > =20 > > The file i would like to store, > > looks like this when i cut and paste > > from notepad. > > =20 > > "FORM =88LWO2TAGS Red Void Void LAYR =12 PNTS = =20 > BBOX VMPA =06VMAP WGHT= =20 > Void.Weight ?=80 POLS FACE PTAG COLR PTAG PART PTAG =20 > SURF [1]SURF =A6Void COLR > ?H=C8=C9?H=C8=C9?H=C8=C9 LUMI =06 DIFF SPEC =06 TRAN = RIND=20 > =06 BUMP GLOS =06 VCOL ?=80 RGBAVoid.Vertex SMAN > -----------------------------------------------------------------------= - > =80 RFOP [1] TROP [1]" > > =20 > > =20 > > Now if i just cut and paste that and write it to a text file, like i=20 > do with Hello World, why does it not work? > > Strangely enough, when i compare the 1byte decimal values of my=20 > written version, and the original version.. > > The first row of numbers are similar, but the 2nd row is different,=20 > and then all the rest similar or identical..... > > for example...=20 > > =20 > > 070 079 082 077 000 000 001 136 076 087 079 050 084 065 071 083 > 000 000 000 016 082 101 100 000 086 111 105 100 000 000 086 111 > 105 100 000 000 076 065 089 082 000 000 000 018 000 000 000 000 > > =20 > > 070 079 082 077 032 032 001 136 076 087 079 050 084 065 071 083 > 032 032 032 016 082 101 100 032 086 111 105 100 032 032 086 111 > 105 100 032 032 076 065 089 082 032 032 032 018 032 032 032 032 > > =20 > > Okay now the script i wrote that originally does this.... > > -----------------------------------------------------------------------= ------------------------------- > > generic > > { > > output =3D File("test.obj","wb"); > > output.writeData(test); > > output.close(); > > @data test > > 070 079 082 077 000 000 001 136 076 087 079 050 084 065 071 083 > 000 000 000 016 082 101 100 000 086 111 105 100 000 000 086 111 > 105 100 000 000 076 065 089 082 000 000 000 018 000 000 000 000 > > @end > > -----------------------------------------------------------------------= ------------------------------------- > > =20 > > =20 > > The main difference, being that WB is used in the script, > > which is obviously, Write Binary..... > > =20 > > Any ideas on how i do the C equivilant? > > here is the sample C code... > > -----------------------------------------------------------------------= ----- > > #include <stdio.h> > #include <stdlib.h> > void main() > { > FILE *myfile; > myfile =3D fopen("test.obj","wb"); > if(!myfile) > { > puts("Some kind of file error!"); > exit(0); > } > fprintf(myfile,"FORM =88LWO2TAGS Red Void Void LAYR =20 > =12 PNTS BBOX =20 > VMPA =06VMAP WGHT Void.Weight ?=80 POLS FACE PTAG =20 > COLR PTAG PART PTAG SURF [1]SURF =A6Void COLR > ?H=C8=C9?H=C8=C9?H=C8=C9 LUMI =06 DIFF SPEC =06 TRAN = RIND=20 > =06 BUMP GLOS =06 VCOL ?=80 RGBAVoid.Vertex SMAN > -----------------------------------------------------------------------= - > =80 RFOP [1] TROP [1]"); > fclose(myfile); > } > > =20 > > So can i use Fprintf, to write my variable "test" which is an an=20 > embedded 1byte decimal format? > > And get it written as binary? > > =20 > > Could it perhaps be something like printf("%03d ",bytes[i] &0xff);}}=20 > (which is a rough guess) > > =20 > > Cheers, > > Scott. > > =20 > http://www.die.net/doc/linux/man/man3/fwrite.3.html #include <stdio.h> #include <stdlib.h> int main() { FILE *myfile; char mydata[]=3D"FORM =88LWO2TAGS Red Void Void LAYR =20 =12 PNTS BBOX =20 VMPA =06VMAP WGHT Void.Weight ?=80 POLS FACE PTAG =20 COLR PTAG PART PTAG SURF [1]SURF =A6Void COLR\ ?H=C8=C9?H=C8=C9?H=C8=C9 LUMI =06 DIFF SPEC =06 TRAN = RIND =06 =20 BUMP GLOS =06 VCOL ?=80 RGBAVoid.Vertex SMAN =80 RFOP [1]= =20 TROP [1]"; myfile =3D fopen("test.obj","wb"); if(!myfile) { puts("Some kind of file error!"); exit(0); } fwrite(&mydata,sizeof(mydata),1,myfile); fclose(myfile); } |
|
From: Scott <fre...@ve...> - 2005-11-10 03:03:36
|
http://www.faqs.org/qa/qa-117.html Cheers, Scott. What is C Because i am using C++ K.N.P |
|
From: Eric E. <eri...@sb...> - 2005-11-10 00:58:41
|
Scott, Also try this site: http://www.cprogramming.com/ Eric -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Scott Sent: Wednesday, November 09, 2005 6:59 PM To: Eric Edwards; dev...@li... Subject: Re: [Dev-C++] Ascii and Binary help Scott, Try out this url: http://www.cprogramming.com/tutorial/cfileio.html Eric Thanks, i will give it a read i did a google search but mostly C++ mentions of binary functions... As i'm only on page 47 of the "introduction to C" from the Online DevC/C++ help.... (it's excellent) Not even up to arrays, or function pointers yet..:) So i'm trying to re-cover all of the basics... But thanks sites like that help.... If anyone else knows of any good online C resources, Library references or anything or reccomened a good book? Cheers, Scott. |
|
From: Scott <fre...@ve...> - 2005-11-10 00:53:39
|
Scott, Try out this url: http://www.cprogramming.com/tutorial/cfileio.html Eric Thanks, i will give it a read i did a google search but mostly C++ mentions of binary functions... As i'm only on page 47 of the "introduction to C" from the Online DevC/C++ help.... (it's excellent) Not even up to arrays, or function pointers yet..:) So i'm trying to re-cover all of the basics... But thanks sites like that help.... If anyone else knows of any good online C resources, Library references or anything or reccomened a good book? Cheers, Scott. |
|
From: Eric E. <eri...@sb...> - 2005-11-10 00:42:07
|
Scott, Try out this url: http://www.cprogramming.com/tutorial/cfileio.html Eric =20 -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Scott Sent: Wednesday, November 09, 2005 6:38 PM To: dev...@li... Subject: [Dev-C++] Ascii and Binary help =20 Okay this is a hard question to phrase.... I'm trying to do a simple command line utility in DevC, to write to a file..... =20 Now i have no problems writing=20 "Hello World" to the screen or text file. =20 But how do i write a binary file? for example... =20 The file i would like to store, looks like this when i cut and paste from notepad. =20 "FORM =88LWO2TAGS Red Void Void LAYR =12 PNTS BBOX VMPA =06VMAP WGHT Void.Weight = ?=80 POLS FACE PTAG COLR PTAG PART PTAG SURF [1]SURF = =A6Void COLR=20 ?H=C8=C9?H=C8=C9?H=C8=C9 LUMI =06 DIFF SPEC =06 TRAN = RIND =06 BUMP GLOS =06 VCOL ?=80 RGBAVoid.Vertex SMAN=20 _____ =20 =80 RFOP [1] TROP [1]" =20 =20 Now if i just cut and paste that and write it to a text file, like i do = with Hello World, why does it not work? Strangely enough, when i compare the 1byte decimal values of my written version, and the original version.. The first row of numbers are similar, but the 2nd row is different, and = then all the rest similar or identical..... for example... =20 =20 070 079 082 077 000 000 001 136 076 087 079 050 084 065 071 083 000 000 000 016 082 101 100 000 086 111 105 100 000 000 086 111 105 100 000 000 076 065 089 082 000 000 000 018 000 000 000 000 =20 070 079 082 077 032 032 001 136 076 087 079 050 084 065 071 083 032 032 032 016 082 101 100 032 086 111 105 100 032 032 086 111 105 100 032 032 076 065 089 082 032 032 032 018 032 032 032 032 =20 Okay now the script i wrote that originally does this.... -------------------------------------------------------------------------= --- -------------------------- generic { output =3D File("test.obj","wb"); output.writeData(test); output.close(); @data test=20 070 079 082 077 000 000 001 136 076 087 079 050 084 065 071 083 000 000 000 016 082 101 100 000 086 111 105 100 000 000 086 111 105 100 000 000 076 065 089 082 000 000 000 018 000 000 000 000 @end -------------------------------------------------------------------------= --- -------------------------------- =20 =20 The main difference, being that WB is used in the script,=20 which is obviously, Write Binary..... =20 Any ideas on how i do the C equivilant? here is the sample C code...=20 -------------------------------------------------------------------------= --- #include <stdio.h> #include <stdlib.h> void main() { FILE *myfile; myfile =3D fopen("test.obj","wb"); if(!myfile) { puts("Some kind of file error!"); exit(0); } fprintf(myfile,"FORM =88LWO2TAGS Red Void Void LAYR =12 PNTS BBOX VMPA =06VMAP = WGHT Void.Weight ?=80 POLS FACE PTAG COLR PTAG PART PTAG = SURF [1]SURF =A6Void COLR=20 ?H=C8=C9?H=C8=C9?H=C8=C9 LUMI =06 DIFF SPEC =06 TRAN = RIND =06 BUMP GLOS =06 VCOL ?=80 RGBAVoid.Vertex SMAN=20 _____ =20 =80 RFOP [1] TROP [1]"); fclose(myfile); } =20 So can i use Fprintf, to write my variable "test" which is an an = embedded 1byte decimal format? And get it written as binary? =20 Could it perhaps be something like printf("%03d ",bytes[i] &0xff);}} = (which is a rough guess) =20 Cheers, Scott. =20 |
|
From: Scott <fre...@ve...> - 2005-11-10 00:32:34
|
Okay this is a hard question to phrase....
I'm trying to do a simple command line
utility in DevC, to write to a file.....
Now i have no problems writing=20
"Hello World" to the screen or text file.
But how do i write a binary file?
for example...
The file i would like to store,
looks like this when i cut and paste
from notepad.
"FORM =01=CB=86LWO2TAGS =10Red Void Void LAYR =12 =
PNTS =0C BBOX =18 VMPA =08 =
=06VMAP =18WGHT =01Void.Weight ?=E2=82=AC POLS =08FACE =01 PTAG =
=08COLR PTAG =08PART =01PTAG =08SURF =02SURF =C2=A6Void =
COLR =0E?H=C3=88=C3=89?H=C3=88=C3=89?H=C3=88=C3=89 LUMI =06 DIFF =
=06 SPEC =06 TRAN =06 RIND =06 BUMP =06 GLOS =
=06 VCOL =16?=E2=82=AC RGBAVoid.Vertex SMAN =04=E2=82=AC RFOP =
=02 TROP =02"
Now if i just cut and paste that and write it to a text file, like i do =
with Hello World, why does it not work?
Strangely enough, when i compare the 1byte decimal values of my written =
version, and the original version..
The first row of numbers are similar, but the 2nd row is different, and =
then all the rest similar or identical.....
for example... =20
070 079 082 077 000 000 001 136 076 087 079 050 084 065 071 083
000 000 000 016 082 101 100 000 086 111 105 100 000 000 086 111
105 100 000 000 076 065 089 082 000 000 000 018 000 000 000 000
070 079 082 077 032 032 001 136 076 087 079 050 084 065 071 083
032 032 032 016 082 101 100 032 086 111 105 100 032 032 086 111
105 100 032 032 076 065 089 082 032 032 032 018 032 032 032 032
Okay now the script i wrote that originally does this....
-------------------------------------------------------------------------=
-----------------------------
generic
{
output =3D File("test.obj","wb");
output.writeData(test);
output.close();
@data test=20
070 079 082 077 000 000 001 136 076 087 079 050 084 065 071 083
000 000 000 016 082 101 100 000 086 111 105 100 000 000 086 111
105 100 000 000 076 065 089 082 000 000 000 018 000 000 000 000
@end
-------------------------------------------------------------------------=
-----------------------------------
The main difference, being that WB is used in the script,=20
which is obviously, Write Binary.....
Any ideas on how i do the C equivilant?
here is the sample C code...=20
-------------------------------------------------------------------------=
---
#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *myfile;
myfile =3D fopen("test.obj","wb");
if(!myfile)
{
puts("Some kind of file error!");
exit(0);
}
fprintf(myfile,"FORM =01=CB=86LWO2TAGS =10Red Void Void LAYR =12 =
PNTS =0C BBOX =18 =
VMPA =08 =06VMAP =18WGHT =01Void.Weight ?=E2=82=AC POLS =
=08FACE =01 PTAG =08COLR PTAG =08PART =01PTAG =08SURF =
=02SURF =C2=A6Void COLR =
=0E?H=C3=88=C3=89?H=C3=88=C3=89?H=C3=88=C3=89 LUMI =06 DIFF =06 =
SPEC =06 TRAN =06 RIND =06 BUMP =06 GLOS =06 =
VCOL =16?=E2=82=AC RGBAVoid.Vertex SMAN =04=E2=82=AC RFOP =02 TROP =
=02");
fclose(myfile);
}
So can i use Fprintf, to write my variable "test" which is an an =
embedded 1byte decimal format?
And get it written as binary?
Could it perhaps be something like printf("%03d ",bytes[i] &0xff);}} =
(which is a rough guess)
Cheers,
Scott.
|
|
From: Richard G. <use...@ya...> - 2005-11-09 19:31:34
|
Chris Irish wrote:
> Richard Gelling wrote:
>
>> Hi,
>>
>> I am working my way through Sams Teach yourself c++ in 21 days and am
>> having a bit fof difficulty with recursion, could someone explain to
>> me how the following oiece of code works:
>>
>> #ifdef HAVE_CONFIG_H
>> #include <config.h>
>> #endif
>>
>> #include <iostream>
>> #include <cstdlib>
>>
>> using namespace std;
>>
>> int toPowerOf( int , int );
>> int main(int argc, char *argv[])
>> {
>> int powerOf, number, result;
>> cout << "\nEnter the number: ";
>> cin >> number;
>> cout << "\nEnter the exponential: ";
>> cin >> powerOf;
>> result = toPowerOf( number, powerOf );
>> cout << "\nThe result of " << number << " to the power of " <<
>> powerOf << " is " << result << endl;
>> return 0;
>> }
>> int toPowerOf( int number, int powerOf )
>> {
>> if ( powerOf == 1 )
>> return number;
>> else
>> {
>> cout << "number is: " << number << " and the power of is " <<
>> powerOf << endl;
>> return ( number * toPowerOf( number, powerOf - 1 ));
>> }
>> }
>>
>> If someone could explain how the recusion side workd I would be
>> gratefull, as I don't seem to be getting anywhere.
>>
>> Thanks a lot
>> Richard G.
>>
>>
> Note: Expand this window till you have the columns all lined up in my
> explanation below.
>
> Well I'm by no means a master of recursion but I believe this example
> works like this...... someone correct me if I'm wrong. Recursion uses
> the a stack for each call to the recursive function. So the first
> call is made, lets say with the values (2,3). Then the first call
> calls itself but with the values (2,2) now, pushing its call onto the
> stack (like a stack of plates). Then the second call calls itself
> again with the values (2,1).... now in the third call..... powerOf ==
> 1, so this stops the recursive calls and the returned value is the
> 2......that call is popped off the stack and that returned 2 it
> multiplied by the 2 in the second call, then the returned value is
> (2*2), the second call is now popped off the stack and that returned
> (2*2) is multiplied by the last 2 (which is the first call's 2).......
> so then "result" is set to 8 which is 2^3.
>
> //push //push //push then
> pop'd //pop
> //pop
> toPowerOf(2,3) toPowerOf(2,2) toPowerOf(2,1) //returns 2
> toPowerOf(2,2) //returns (2*2) toPowerOf(2,3)
> toPowerOf(2,3) toPowerOf(2,2)
> toPowerOf(2,3)
> toPowerOf(2,3)
>
> The last one returns 2*2*2
>
> Hope that helps...... I find recursion difficult too :)
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
> Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
Thanks for that everyone, that's made it clearer, I think I was
suffering from a mental block,
|
|
From: <ps...@ma...> - 2005-11-09 10:27:46
|
> Richard Gelling <use...@ya...> wrote > Hi, > I am working my way through Sams Teach yourself c++ in 21 days and am having a bit fof difficulty with recursion, > could someone explain to me how the following oiece of code works: This reminds me of the old adage: to understand recursion, first, one must understand recursion. This may not have helped much, but some day in the future, we'll all look back on this moment and laugh. -- http://www.fastmail.fm - Access your email from home and the web |
|
From: Robert A. <ral...@gm...> - 2005-11-09 01:39:09
|
Recursion works by solving a simpler problem. In the case above you know
that if you raise any number to the 1st power then you get that number back=
,
Otherwise you can get the result by multipling the number by the number
raised to the initial power minus one.
So if I am going to raise 10 to the third power ie pow(10,3)
pow(10,3)=3D10*pow(10,2)
pow(10,2)=3D10*pow(10,1)
pow(10,1)=3D10
So... now backing up as each function returns you get
pow(10,3)=3D10*10*10
On 11/8/05, Richard Gelling <use...@ya...> wrote:
>
> Hi,
>
> I am working my way through Sams Teach yourself c++ in 21 days and am
> having a bit fof difficulty with recursion, could someone explain to me
> how the following oiece of code works:
>
> #ifdef HAVE_CONFIG_H
> #include <config.h>
> #endif
>
> #include <iostream>
> #include <cstdlib>
>
> using namespace std;
>
> int toPowerOf( int , int );
> int main(int argc, char *argv[])
> {
> int powerOf, number, result;
> cout << "\nEnter the number: ";
> cin >> number;
> cout << "\nEnter the exponential: ";
> cin >> powerOf;
>
> result =3D toPowerOf( number, powerOf );
>
> cout << "\nThe result of " << number << " to the power of " <<
> powerOf << " is " << result << endl;
>
> return 0;
> }
> int toPowerOf( int number, int powerOf )
> {
> if ( powerOf =3D=3D 1 )
> return number;
> else
> {
> cout << "number is: " << number << " and the power of is " <<
> powerOf << endl;
> return ( number * toPowerOf( number, powerOf - 1 ));
> }
> }
>
> If someone could explain how the recusion side workd I would be
> gratefull, as I don't seem to be getting anywhere.
>
> Thanks a lot
>
> Richard G.
>
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
> Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Chris I. <chr...@li...> - 2005-11-08 23:36:53
|
Looks like the formatting came out all screwy..... here's a screenshot of what it should look like Later, Chris |
|
From: Chris I. <chr...@li...> - 2005-11-08 23:21:41
|
Richard Gelling wrote:
> Hi,
>
> I am working my way through Sams Teach yourself c++ in 21 days and am
> having a bit fof difficulty with recursion, could someone explain to
> me how the following oiece of code works:
>
> #ifdef HAVE_CONFIG_H
> #include <config.h>
> #endif
>
> #include <iostream>
> #include <cstdlib>
>
> using namespace std;
>
> int toPowerOf( int , int );
> int main(int argc, char *argv[])
> {
> int powerOf, number, result;
> cout << "\nEnter the number: ";
> cin >> number;
> cout << "\nEnter the exponential: ";
> cin >> powerOf;
> result = toPowerOf( number, powerOf );
> cout << "\nThe result of " << number << " to the power of " <<
> powerOf << " is " << result << endl;
> return 0;
> }
> int toPowerOf( int number, int powerOf )
> {
> if ( powerOf == 1 )
> return number;
> else
> {
> cout << "number is: " << number << " and the power of is " <<
> powerOf << endl;
> return ( number * toPowerOf( number, powerOf - 1 ));
> }
> }
>
> If someone could explain how the recusion side workd I would be
> gratefull, as I don't seem to be getting anywhere.
>
> Thanks a lot
> Richard G.
>
>
Note: Expand this window till you have the columns all lined up in my
explanation below.
Well I'm by no means a master of recursion but I believe this example
works like this...... someone correct me if I'm wrong. Recursion uses
the a stack for each call to the recursive function. So the first call
is made, lets say with the values (2,3). Then the first call calls
itself but with the values (2,2) now, pushing its call onto the stack
(like a stack of plates). Then the second call calls itself again with
the values (2,1).... now in the third call..... powerOf == 1, so this
stops the recursive calls and the returned value is the 2......that call
is popped off the stack and that returned 2 it multiplied by the 2 in
the second call, then the returned value is (2*2), the second call is
now popped off the stack and that returned (2*2) is multiplied by the
last 2 (which is the first call's 2)....... so then "result" is set to 8
which is 2^3.
//push //push //push then pop'd
//pop //pop
toPowerOf(2,3) toPowerOf(2,2) toPowerOf(2,1) //returns 2
toPowerOf(2,2) //returns (2*2) toPowerOf(2,3)
toPowerOf(2,3) toPowerOf(2,2)
toPowerOf(2,3)
toPowerOf(2,3)
The last one returns 2*2*2
Hope that helps...... I find recursion difficult too :)
|
|
From: Richard G. <use...@ya...> - 2005-11-08 22:27:29
|
Hi,
I am working my way through Sams Teach yourself c++ in 21 days and am
having a bit fof difficulty with recursion, could someone explain to me
how the following oiece of code works:
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <iostream>
#include <cstdlib>
using namespace std;
int toPowerOf( int , int );
int main(int argc, char *argv[])
{
int powerOf, number, result;
cout << "\nEnter the number: ";
cin >> number;
cout << "\nEnter the exponential: ";
cin >> powerOf;
result = toPowerOf( number, powerOf );
cout << "\nThe result of " << number << " to the power of " <<
powerOf << " is " << result << endl;
return 0;
}
int toPowerOf( int number, int powerOf )
{
if ( powerOf == 1 )
return number;
else
{
cout << "number is: " << number << " and the power of is " <<
powerOf << endl;
return ( number * toPowerOf( number, powerOf - 1 ));
}
}
If someone could explain how the recusion side workd I would be
gratefull, as I don't seem to be getting anywhere.
Thanks a lot
Richard G.
|
|
From: massimiliano c. <ci...@gm...> - 2005-11-08 15:19:47
|
On 11/8/05, Per Westermark <pw...@ia...> wrote: > Do you open the files as binary or as text? as text (default) -- Massimiliano Cialdi ci...@gm... m.c...@ok... |
|
From: Per W. <pw...@ia...> - 2005-11-08 15:18:39
|
Do you open the files as binary or as text? /Per W On Tue, 8 Nov 2005, massimiliano cialdi wrote: > I use mingw-gcc 3.4.2 provided by DevCpp 4.9.9.2 beta 9. > It seems that gcc (or only some components like libstdc++) is compiled > using unix style EOL (LF) instead of win style (CR+LF). > I have tested it with a simple program that read lines from a text > file and print them out. > > http://mastupristi.altervista.org/test_ifstream.zip > Here is the sample project. There are two text file: testunix.test and > testwin.test (with different EOL style). If you try to execute the > program you can see that it works properly only with testunix.test. > Now the question is: "How can I make it works with windows style EOL?" > > please note that compiling with mingw-gcc 3.2.3, or under linux, the > programs works well... > > thanks > > -- > Massimiliano Cialdi > ci...@gm... > m.c...@ok... > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App Server. Download > it for free - -and be entered to win a 42" plasma tv or your very own > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: massimiliano c. <ci...@gm...> - 2005-11-08 15:08:31
|
I use mingw-gcc 3.4.2 provided by DevCpp 4.9.9.2 beta 9. It seems that gcc (or only some components like libstdc++) is compiled using unix style EOL (LF) instead of win style (CR+LF). I have tested it with a simple program that read lines from a text file and print them out. http://mastupristi.altervista.org/test_ifstream.zip Here is the sample project. There are two text file: testunix.test and testwin.test (with different EOL style). If you try to execute the program you can see that it works properly only with testunix.test. Now the question is: "How can I make it works with windows style EOL?" please note that compiling with mingw-gcc 3.2.3, or under linux, the programs works well... thanks -- Massimiliano Cialdi ci...@gm... m.c...@ok... |
|
From: <MFr...@to...> - 2005-11-08 05:00:00
|
I will be out of the office starting 11/05/2005 and will not return until 11/15/2005. I will be reviewing all messages when I return and will respond as promptly as possible at that time. Thank You. ****************************** Matt Freeman Tomax Corporation Phone - 801.924.6300 ext. 6353 Fax - 801.415.6553 mfr...@to... http://www.tomax.com/ ****************************** |
|
From: Frans E. <fra...@te...> - 2005-11-07 16:54:42
|
Hello all, I have a design problem which I don't know how to solve the best way. In my code I almost exclusively handle heap allocated objects, and accesses them via reference counting pointers(the counting is in the object, not the pointer). The problem emerges when invoking operators between objects. This looks for example like this[1]: Cardinality::Ptr(&(*opCard | *Cardinality::zeroOrOne)))); Evidently, this is not very pretty, when compared to the expression: opCard | Cardinality::zeroOrOne I'm taking the "| operator" as a representative example of my general problem. It's signature looks like this: Cardinality &operator|(const Cardinality &other) const; I wonder, should I add/change operators such that using the classes are more convenient? For example, I could change the operator to: Cardinality::Ptr &operator|(const Cardinality::Ptr &other) const; and thus reduce "Cardinality::Ptr(&(*opCard | *Cardinality::zeroOrOne))));" into "*opCard | Cardinality::zeroOrOne". Another alternative is to add in the default namespace: inline Cardinality::Ptr operator(const Cardinality::Ptr &o1, const Cardinality:Ptr &o2) /* ... */ which probably is the cleanest solution, and would result in "opCard | Cardinality::zeroOrOne" What makes me wonder is that I don't want to couple a smart pointer, which is more of a tool for memory management, to my classes(although they wouldn't live without the smart pointer). Somehow, I want to keep it modularized and separated. On the other hand, "Cardinality::Ptr(&(*opCard | *Cardinality::zeroOrOne))))" is very ugly, and perhaps a freestanding operator involving Cardinality::Ptr is modularized enough. What do people think? What is the cleanest solution? pros/cons? Cheers, Frans 1. Nope, I'm not defeferencing a temporary object because the | operator returns a (valid) reference. |
|
From: Marcelo D. <mds...@ya...> - 2005-11-07 16:23:09
|
I think you can't call a constructor like a function. You need a Set() Method or this: --- in main() --- HEAP<ELEMENT> A(10); //THIS WORKS FINE /******>>> not here HEAP<ELEMENT> B; // I CAN'T DO THIS *******/ THOUGH...why?? how can I?? int size; cout << "Give the desired size of this heap: " << endl; cin >> size; /*****>>> here <<<*****/ HEAP<ELEMENT> B(size); // I CAN'T DO THIS INSTANTIATE B DOWN HERE (o_o) - mds GATBRASIL _______________________________________________________ Yahoo! Acesso Grátis: Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/ |
|
From: Richard V. W. <ric...@ai...> - 2005-11-07 07:08:25
|
Hi, You are creating an object called B, but there is no default constructor for the class (a constructor with no parameters). The only constructor takes an int parameter. As I see it you want to be able to modify the heap size dynamically, So maybe you can add a method called SetHeapSize(int i) that takes care of assigning or freeing memory, and this can be called anytime. You can only create an object once. Another aproach.. Not sure about template classes, but perhaps you can declare a POINTER to an object and call it B and Create the object later on using 'new'. Cheers, Richard |
|
From: Chris I. <chr...@li...> - 2005-11-07 04:42:00
|
Hello all :)
Hopefully someone can shed some light on this problem I'm having. I'm
trying to declare a variable to a type of class I've defined (which is
a minHeap), but actually instantiate it later when I get a command from
the user. This is my class and if you look down a lil you can see what
I'm trying to do in my main(). I want to ask for the size from the
user, but when I try to I can't get my code to compile. Here is the
class definition and the constructor. This is the error I'm getting.
/Users/ci/minheap/minheap.h:42: error: prototype for 'HEAP<T>::HEAP()'
does not match any in class 'HEAP<T>'
I've been reading up on smart pointers but i'm not sure if that's what
I'm suppose to be using. Any help/info would help me alot.......
THANKS
#-------------------------------------------------------------
#include <cstdlib>
#include <iostream>
using namespace std;
struct ELEMENT{int key;};
template<class T>
class HEAP {
public:
HEAP(int n);
~HEAP(){ delete [] heap;}
T Min(){if (CurrentSize == 0)
throw OutOfBounds();
return heap[0];}
HEAP<T>& Insert(int k);
int DeleteMin();
void printHeap() const;
private:
int CurrentSize, Capacity;
T *heap; // element array
};
template<class T>
HEAP<T>::HEAP(int n){ //constructor.
Capacity = n;
cout << "Heap's Capacity is: " << Capacity << endl;
heap = new ELEMENT[Capacity];
CurrentSize = 0;
}
int main(void){
HEAP<ELEMENT> A(10); //THIS WORKS FINE
HEAP<ELEMENT> B; // I CAN'T DO THIS THOUGH...why?? how can
I??
int size;
cout << "Give the desired size of this heap: " << endl;
cin >> size;
B(size); // I WANT TO INSTANTIATE B DOWN HERE
}
|
|
From: cwic <cw...@ma...> - 2005-11-04 07:12:04
|
Hello Chris, Thursday, November 3, 2005, 11:57:07 PM, you wrote: CI> Hello all.... 1st post here welcome! ;) CI> I was hoping someone could tell me how you test the datatype of a CI> variable in C++? Run-time type information (RTTI) is a mechanism that allows the type of an object to be determined during program execution. http://search.microsoft.com/search/results.aspx?qu=RTTI&View=msdn&st=b&c=4&s=1&swc=4 -- Best regards, cwic mailto:cw...@ma... |
|
From: Chris I. <chr...@li...> - 2005-11-03 21:57:08
|
Hello all.... 1st post here
I was hoping someone could tell me how you test the datatype of a
variable in C++?
Like if I declare
struct ELEMENT{int key;} variable1;
OR
int variable2 = 10;
How can I type check variable1 or variable2?
I mostly write in Python and I'm looking for something like
type(variable1) #would return the datatype of variable1
or
isinstance(variable2, int) #would return true is variable2 is a
instance of the int class
Thanks in advance,
Chris
|
|
From: warbad c. <wa...@ya...> - 2005-11-03 18:00:49
|
Hello all,
I'm new here, so i hope i'll make no mistake posting
my problem.
I've wrote a quick test program in c:
#ifndef DOMAIN_H
#define DOMAIN_H
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <lm.h>
#endif /* DOMAIN_H */
#include "domain.h"
int main(int argc, char *argv[])
{
NET_API_STATUS res;
printf("You're about to change the computer name to
%s\n", argv[1]);
res = NetRenameMachineInDomain (
NULL, argv[1], "myaccount" , "mypassword",
NETSETUP_ACCT_CREATE);
if (res != NERR_Success) { printf("Error!!!\n"); }
system("PAUSE");
return 0;
}
I setup (i think correctly) the link to libs,
includes, etc..
but when i try to compile i have many many errors :
Compiler: Default compiler
Building Makefile: "D:\Documents and
Settings\dev\Domain\Makefile.win"
Executing make...
make.exe -f "D:\Documents and
Settings\dev\Domain\Makefile.win" all
gcc.exe -D__DEBUG__ -c domain.c -o domain.o
-I"C:/Program Files/Microsoft Platform SDK/Include"
-I"C:/Program Files/Microsoft Platform SDK/Include"
-Wall -g -g3
In file included from domain.h:6,
from domain.c:1:
C:/Program Files/Microsoft Platform
SDK/Include/windows.h:157:19: excpt.h: No such file or
directory
In file included from C:/Program Files/Microsoft
Platform SDK/Include/winnt.h:99,
from C:/Program Files/Microsoft
Platform SDK/Include/windef.h:176,
from C:/Program Files/Microsoft
Platform SDK/Include/windows.h:161,
from domain.h:6,
from domain.c:1:
C:/Program Files/Microsoft Platform
SDK/Include/basetsd.h:63: error: parse error before
"INT64"
C:/Program Files/Microsoft Platform
SDK/Include/basetsd.h:63: warning: type defaults to
`int' in declaration of `INT64'
[...]
I never succeed to write a program with the PSDK.
If someone can help, he'll be great
Thank in advance.
Vincent
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com
|
|
From: Guillermo G. <ggu...@ma...> - 2005-11-03 15:19:47
|
Tell you what Kishan,=20 Email me directly, I think I can help you out. -----Original Message----- From: dev...@li... [mailto:dev...@li...]On Behalf Of Per Westermark Sent: Wednesday, November 02, 2005 11:03 PM To: KISHAN PATEL Cc: eri...@sb...; gc...@gc...; dev...@li... Subject: RE: [Dev-C++] C# Sorry, nobody knows how to do it in C# with Dev-C++. Dev-C++ is for C = and C++ programs... /Per W On Wed, 2 Nov 2005, KISHAN PATEL wrote: > > Does anyone know how to write a program that should read two numbers = and then find the smaller one and find it's square and then divide by 2 > > > > > K.N.P > > = _________________________________________________________________________= _________________________________________________________________________= _ > Search, shop, and browse smarter using tabs with the MSN Search = Toolbar-FREE! ------------------------------------------------------- = SF.Net > email is sponsored by: Tame your development challenges with Apache's = Geronimo App Server. Download it for free - -and be entered to win a > 42" plasma tv or your very own Sony(tm)PSP. Click here to play: = http://sourceforge.net/geronimo.php > _______________________________________________ Dev-cpp-users mailing = list Dev...@li... TO UNSUBSCRIBE: > http://www23.brinkster.com/noicys/devcpp/ub.htm = https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > ------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. = Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: Per W. <pw...@ia...> - 2005-11-03 07:02:54
|
Sorry, nobody knows how to do it in C# with Dev-C++. Dev-C++ is for C and C++ programs... /Per W On Wed, 2 Nov 2005, KISHAN PATEL wrote: > > Does anyone know how to write a program that should read two numbers and then find the smaller one and find it's square and then divide by 2 > > > > > K.N.P > > ___________________________________________________________________________________________________________________________________________________ > Search, shop, and browse smarter using tabs with the MSN Search Toolbar-FREE! ------------------------------------------------------- SF.Net > email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a > 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: > http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |