Can someone please tell me about an alternative command that I can use instead of the system() function?

I have another question - If system("pause") only pauses the program before it exits, can I use getch() funtion from the conio.h header file for that purpose.(I know i can use the cin.get() function, but i'm just asking.)

Please answer, i'm a beginner in C++ programming.

Alternative to system: fork() with exec* on linux or CreateProcess on Windows. popen (a convenience wrapper around the previous method)

Using getch() :
If you are looking to stop execution while you wait for user input any valid call that blocks on user input is valid. Not each method is necessarily valid across all systems, which is why one may want to prefer cin.get() .

Alternative to system: fork() with exec* on linux or CreateProcess on Windows. popen (a convenience wrapper around the previous method)

Using getch() :
If you are looking to stop execution while you wait for user input any valid call that blocks on user input is valid. Not each method is necessarily valid across all systems, which is why one may want to prefer cin.get() .

Can you please explain fork() , CreateProcess and popen a bit more, with the syntax?

Oops! I had completely forgotten that I could just google 'em.:P
BTW, I found this code about fork() :
Code from http://ubuntuforums.org/showthread.php?t=794481:

#include <stdio.h>
#include <unistd.h>
/*
You are free to change my name with yours :)
*/
int main()
{
    printf("Fork example. Brought you by Dushan Savich, also known as dempl_dempl \n");


int pid = fork();

if(pid == 0)
{
     printf("Hello, everybody!  I\'m a child program/process !\n"); 
}
else
{
  printf("Hello, kids!  I\'m a daddy process ! My child's process id [ pid ] is %d\n" , pid);
}

  printf("This one you will see in both programs!! It should be printed twice. Bye!\n");
 
return 0; 
}

When I try to compile the program, my compiler give an error: 'fork'undeclared(first use this function) Does this happen coz i'm trying to compile it on windows, rather than on linux?
Oh, and I use Bloodshed Dev-Cpp as my compiler.

Yes. As I originally pointed out, to spawn a new process on linux you'd use fork/exec and on Windows, CreateProcess .

As an aside, the link you provide is from an Ubuntu forum. Ubuntu is a linux distribution. You seem like you may want to include the terms "on windows" in any search to narrow results to relevant locations.

Edited 5 Years Ago by L7Sqr: n/a

Thanx to everyone for your help.
BTW, can anybody suggest me a good c++ compiler for Puppy Linux 5.1.1?

This question has already been answered. Start a new discussion instead.