Re: Regarding system function
- From: rlb@xxxxxxxxxxxxxxxxxxxxxx (Richard Bos)
- Date: Fri, 06 Oct 2006 07:41:30 GMT
"sunil" <sunil.vvn@xxxxxxxxx> wrote:
#include<stdlib.h>
int i = system("pwd");
I compiled the above program in UNIX ,it got compiled and
executed with out any errors.
Well, that's wrong, then. Time to hitch up the warning level on your
compilations, or to stop compiling GNU almost-but-not-quite-C.
From the Standard, paragraph 6.7.8, item 4: "All the expressions in aninitializer for an object that has static storage duration shall be
constant expressions or string literals". A function call is not a
constant expression or a string literal; therefore, this code is not
correct C.
It prints the present working directory.Am
having certain doubts about this program.
1) without main how it got executed
It shouldn't have been.
2)is the system funcion is static
That does not make sense. Objects can have static duration; functions
just _are_.
3) is the shell had executed that system command
Well, yes, of course. That's what system() is for, after all.
4) how return type is playing a role,is it mandatory
to collect the return type in C(upto my knowledge it's not mandatory to
collect the return type).
No.
In case of any queries please revert me back.
Yer_what_? "Please revert me back"? Ok, if you say so... If someone
sends in a query I'll ditch today's version of you and go back to the
backup you made yesterday.
Richard
.
- Follow-Ups:
- Re: Regarding system function
- From: Rod Pemberton
- Re: Regarding system function
- From: jacob navia
- Re: Regarding system function
- References:
- Regarding system function
- From: sunil
- Regarding system function
- Prev by Date: Re: Pointers to dead objects
- Next by Date: Re: PASCAL'S TRIANGLE
- Previous by thread: Regarding system function
- Next by thread: Re: Regarding system function
- Index(es):