V
Vipin
I tried following two programs and I am seeing an unusual behavior
here.
what can be the reason for the same ??
/* ------ main.c ----- */
#include <stdio.h>
#include <stdlib.h>
int main (int argc , char *argv[]){
printf("\nI am in main.");
#ifdef unix
system("./main2");
#else
system(".\\main2.exe");
#endif
printf("\n Tried to invoke executable");
return 0;
}
/* -------main2.c----------*/
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[]){
printf("\n I am running in main2\n ");
return 0;
}
--> both the progs are in the same diretory
--> I do the following
$gcc -o main2 main2.c
$gcc -o main main.c
$./main
is see the following result
RESULT
--------------------
I am running in main2
I am in main.
Tried to invoke executable
I have the concern that why the second line gets printed in after the
first. If you see in main.c, it was printed before invoking "main2".
shouldn't the behavior of program be exactly sequential.
here.
what can be the reason for the same ??
/* ------ main.c ----- */
#include <stdio.h>
#include <stdlib.h>
int main (int argc , char *argv[]){
printf("\nI am in main.");
#ifdef unix
system("./main2");
#else
system(".\\main2.exe");
#endif
printf("\n Tried to invoke executable");
return 0;
}
/* -------main2.c----------*/
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[]){
printf("\n I am running in main2\n ");
return 0;
}
--> both the progs are in the same diretory
--> I do the following
$gcc -o main2 main2.c
$gcc -o main main.c
$./main
is see the following result
RESULT
--------------------
I am running in main2
I am in main.
Tried to invoke executable
I have the concern that why the second line gets printed in after the
first. If you see in main.c, it was printed before invoking "main2".
shouldn't the behavior of program be exactly sequential.