Thread: Re: [Dev-C++] First experience with Dev-C++
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Joshua T. <vap...@ms...> - 2002-01-20 20:01:05
|
printf() function is a C antique, so its considered bad style so I used c=
out which conforms to ANSI standard...See notes at bottem for further com=
ments. Let me know if you need more help. =20
Joshua Thomas
// Try the code this way: =20
=20
#include <iostream>
#include <stdlib.h>
int main(char * argv =3D new char [1024], int argc)
{
cout << "Hello Dev-C++"; //displays text in quotes... << directs t=
he string to cout
=20
delete [] argv; //deletes array and pointer, so there is no memor=
y leak
=20
float wait =3D 0;
while (wait < 1E9) //see program notes
wait++;
=20
return 0;
}
// Program notes: while loop makes the computer count to 1 billion before=
closing the console window. This may or may =20
// not be enough time depending on your computer. You can use the ctime l=
ibrary to make the program more portable.
// (setting the program keep time in seconds not computer processing tick=
s through use of the while loop) Also note that =20
// stdio.h is not a valid library I believe you were looking for stdlib. =
Also your pointer syntax was off I fixed it and set the =20
// pointer argv to point to an array with the size of 1 MB of chars. (102=
4 variables in array of type char formally)
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Hello Dev-C++");
return 0;
}
//
Well; from command line: g++ b.cpp it compiles and create a.exe
correctly. But from Dev-C++ I have just this list of errors:
c:\mingw\bin\ld.exe: warning: cannot find entry symbol _mainCRTStartup;
defaulting to 00401000
c:\a2\b.o(.text+0x17)://c/a2/b.cpp: undefined reference to `__main'
c:\a2\b.o(.text+0x24)://c/a2/b.cpp: undefined reference to `printf'
What am I missing?
- I have installed MingW at c:\mingw
- Dev-C++ is configuraed this way:
- bin directory: c:\mingw\bin\
- C include files c:\mingw\include\
- C++ include files c:\mingw\include\
- Libraries directory c:\mingw\lib\
- OS: W2k
Thanks a lot!
--
Jilani Khaldi
http://space.tin.it/scuola/jkhaldi
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
https://lists.sourceforge.net/lists/listinfo/dev-cpp-usersGet more from t=
he Web. FREE MSN Explorer download : http://explorer.msn.com
|
|
From: <Ech...@ne...> - 2002-01-22 17:22:04
|
The printf() function is a C function, but not an antique. In fact, I find that many C++ projects use printf instead of cout (at least most of the one's that I am familiar with). Printf has more powerfull formatting features that cout . One disadvantage to printf is that it cannot print out classes which cout can do.
Evan
Message: 15
From: "Joshua Thomas" <vap...@ms...>
To: "Jilani Khaldi" <ji...@ti...>,
<Dev...@li...>
Subject: Re: [Dev-C++] First experience with Dev-C++
Date: Sun, 20 Jan 2002 15:02:39 -0500
------=_NextPart_001_0000_01C1A1C3.808E7940
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
printf() function is a C antique, so its considered bad style so I used c=
out which conforms to ANSI standard...See notes at bottem for further com=
ments. Let me know if you need more help. =20
Joshua Thomas
// Try the code this way: =20
=20
#include <iostream>
#include <stdlib.h>
int main(char * argv =3D new char [1024], int argc)
{
cout << "Hello Dev-C++"; //displays text in quotes... << directs t=
he string to cout
=20
delete [] argv; //deletes array and pointer, so there is no memor=
y leak
=20
float wait =3D 0;
while (wait < 1E9) //see program notes
wait++;
=20
return 0;
}
// Program notes: while loop makes the computer count to 1 billion before=
closing the console window. This may or may =20
// not be enough time depending on your computer. You can use the ctime l=
ibrary to make the program more portable.
// (setting the program keep time in seconds not computer processing tick=
s through use of the while loop) Also note that =20
// stdio.h is not a valid library I believe you were looking for stdlib. =
Also your pointer syntax was off I fixed it and set the =20
// pointer argv to point to an array with the size of 1 MB of chars. (102=
4 variables in array of type char formally)
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Hello Dev-C++");
return 0;
}
//
Well; from command line: g++ b.cpp it compiles and create a.exe
correctly. But from Dev-C++ I have just this list of errors:
c:\mingw\bin\ld.exe: warning: cannot find entry symbol _mainCRTStartup;
defaulting to 00401000
c:\a2\b.o(.text+0x17)://c/a2/b.cpp: undefined reference to `__main'
c:\a2\b.o(.text+0x24)://c/a2/b.cpp: undefined reference to `printf'
What am I missing?
- I have installed MingW at c:\mingw
- Dev-C++ is configuraed this way:
- bin directory: c:\mingw\bin\
- C include files c:\mingw\include\
- C++ include files c:\mingw\include\
- Libraries directory c:\mingw\lib\
- OS: W2k
Thanks a lot!
--
Jilani Khaldi
http://space.tin.it/scuola/jkhaldi
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
https://lists.sourceforge.net/lists/listinfo/dev-cpp-usersGet more from t=
he Web. FREE MSN Explorer download : http://explorer.msn.com
--
__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/
Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
|
|
From: Kevin W. <ke...@me...> - 2002-01-21 14:17:29
|
Sorry, Joshua, but your code is not correct. You should not declare
variables / storage space in the argument list of a function. What do you
intend to do with 1Mb of memory? You would not be able to access the
command-line arguments.
There's nothing wrong with printf - it is ANSI compatible. If being antique
means it's considered bad style, then I'm WELL out of style (50 this year!),
but I still consider myself to be useful.
Does no one use the console program template which comes with DEV C++ ?
Kev.
---------------------------------------------------------------------------
----- Original Message -----
From: Joshua Thomas <vap...@ms...>
To: Jilani Khaldi <ji...@ti...>; <Dev...@li...>
Sent: Sunday, January 20, 2002 8:02 PM
Subject: Re: [Dev-C++] First experience with Dev-C++
printf() function is a C antique, so its considered bad style so I used cout
which conforms to ANSI standard...See notes at bottem for further comments.
Let me know if you need more help.
Joshua Thomas
// Try the code this way:
#include <iostream>
#include <stdlib.h>
int main(char * argv = new char [1024], int argc)
{
cout << "Hello Dev-C++"; //displays text in quotes... << directs the
string to cout
delete [] argv; //deletes array and pointer, so there is no memory
leak
float wait = 0;
while (wait < 1E9) //see program notes
wait++;
return 0;
}
--- snip -----
|