cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
UNIX/Linux Programming
Quick system() question
Quick system() question
Aug 12, 2010 at 5:42am UTC
amma
(27)
I have a program which calls vim, allows the user to edit a file, and then returns to the program. For the moment I just to system ("vim new") but this produces a crash. Mustn't I pause something before I return to my program?
Aug 23, 2010 at 3:24pm UTC
vvadan
(36)
int main()
{
system("vim new");
cout << "vim done" << endl;
return 0;
}
Amma, the above is a sample program which works perfectly right. By the way what is the OS you are working on?
Aug 23, 2010 at 4:08pm UTC
chrisname
(7395)
Please don't use the system() function; if you want to know why (and you should) you can read here:
http://www.cplusplus.com/forum/articles/11153/
If you want the program to be done the Right Way (that is, safely, securely and efficiently) you should use the fork(), exec?() and waitpid() functions:
fork():
http://linux.die.net/man/2/fork
exec?():
http://linux.die.net/man/3/exec
waitpid():
http://linux.die.net/man/2/waitpid
Topic archived. No new replies allowed.