Top

Discussion

What will the following C code do on compilation?

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

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.

No comment is present. Be the first to comment.
Loading…

Post your comment