What will the following C code do on compilation? [code]void main () { char com[50]; strcpy( com, "dir" ); system(com); }

What will the following C code do on compilation?
Code:
void main () 
{
   char com[50];  
   strcpy( com, "dir" ); 
   system(com); 
}
A. error
B. lists down all the files and directories in the current directory under windows machine
C. terminates the calling process immediately
D. calls specified function and terminates it at the end of the program
 
Answer: b
Explanation: int system(const char *command) function is used to pass the command name or the program name specified by command to the host environment to be executed by the command processor and returns after the command has been completed.
 

Tìm kiếm

Back
Top