RE: Fw: [Dev-C++] First experience with Dev-C++
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ya...> - 2002-01-22 15:12:42
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Luigi Santillo
> Sent: Tuesday, January 22, 2002 3:49 PM
> To: dev...@li...
> Subject: Re: Fw: [Dev-C++] First experience with Dev-C++
>
>
> Hello list,
>
> Consider me as a newbie, I just know (or think to know) a few
> elementary
> things about C (I mean "antique" ANSI C-89).
I wouldn't say it is an antique. :)
> According to two recent posts, I received from this list, the
> following
> code (by Jilani Khaldi) does not work:
>
> #include <stdio.h>
> int main(int argc, char *argv[])
> {
> printf("Hello Dev-C++");
> return 0;
> }
This is C and it works, although the main arguments are not needed.
> While the following (by Joshua Thomas) is a working version of it:
>
> #include <iostream>
> #include <stdlib.h>
> int main(char * argv = new char [1024], int argc)
> {
> cout << "Hello Dev-C++";
>
> delete [] argv;
>
> float wait = 0;
> while (wait < 1E9) //see program notes
> wait++;
>
> return 0;
> }
This is C++ code but it is WRONG. Although it compiles strangely in
Dev-C++ it is WRONG. You can't delete argv since it is a static object
on the stack and not on the free store. Also it should be char *argv[]
or char **argv.
Also after the official C++ standard he should have used the using
namespace std; or using std::cout directives.
>
> Excluding the "float wait" stuff (not required if one runs
> applications
> from the command line), I'm a little confused:
> - is the second version written in "modern" ANSI C-98 (hope
> the year is
> right)?
The name is ANSI C99 and the answer is no. The code was a C++ attempt.
> - what need is there to include "stdlib.h"?
None. stdlib.h is not needed in that code.
> - is the order of the parameters correct in the first or in
> the second version?
The order of parameters doesn't matter.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.d2g.com
* Alternative URL: http://run.to/noicys
|