executing commands

hello
i want to open gedit text editor and the without closing it the other commands be executed how i can do it?
1
2
3
4
5
6
7
8
9
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
  system("gedit /home/sajad/welcome.txt");
  system("totem /home/sajad/001.mp3");
  cout<<"this is the end of my program!"<<endl;
}

Please use <cstdlib> rather than the old, deprecated <stdlib.h>
Put an & sign after each command like this:

1
2
3
4
5
6
7
8
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
  system("gedit /home/sajad/welcome.txt &");
  system("totem /home/sajad/001.mp3 &");
  cout<<"this is the end of my program!"<<endl;
}


That tells the system to put the process in the background so that other commands can run at the same time.


Last edited on
ok thanks,this works properly.
Topic archived. No new replies allowed.