how to use system() in c

September 12, 2011 at 23:47:14
Specs: Windows XP, 2gb
i don't know how to use system() ,please help me with working examples

See More: how to use system() in c

Report •


#1
September 13, 2011 at 05:49:12
system("dir /b");

char cmd[200] = { 0 };
sprintf(cmd, "dir %s /b", "c:\\progra~1");
system(cmd);

char cmd[200] = { 0 };
sprintf(cmd, "notepad %s", "some_drive:\\some_path\\some_file.txt");
system(cmd);

stuff like that... typically, what you can do from the command prompt.

HTH


Report •

#2
September 13, 2011 at 06:43:37
it's not working ,the system () returns -1

Report •

#3
September 13, 2011 at 07:51:08
Then check errno to find out what went wrong.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
September 15, 2011 at 19:13:44
i want some notes about system() in c with examples

Report •

#5
September 16, 2011 at 15:22:37
Fine.
#include <cstdlib>
int main() {
  std::system("PAUSE");
  return 0;
}

How To Ask Questions The Smart Way


Report •

Ask Question