Skip to content

Instantly share code, notes, and snippets.

@figengungor
Last active December 24, 2015 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save figengungor/6873724 to your computer and use it in GitHub Desktop.
Save figengungor/6873724 to your computer and use it in GitHub Desktop.
Child Process in Windows Lab1
#include<stdio.h>
#include<Windows.h>
int main(int argc, char* argv[])
{
//we'll execute this child process with one argument from parent process,
//so we are checking if the number of arguments is right.
//If you wanna give more arguments, check according to this.
//argc is the number of arguments + 1(process that is executed)
// ex: child.exe 1 => argc=2 , calculator.exe "what's up?" "hey" "yov" 4 => argc=5
if(argc!=2)
{
printf("error in child process");
system("pause");
exit(0);
}
//if everything goes right, then let's print the argument given to this child.
//argv[0] is the name of process(child.exe in this case), argv[1] is first arg, argv[2] is second
//and it goes on as you wish.
printf("message from parent: %s \n", argv[1]);
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment