LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Guess output of this program? (https://www.linuxquestions.org/questions/linux-newbie-8/guess-output-of-this-program-818313/)

vivignesh 07-06-2010 01:06 PM

Guess output of this program?
 
Guess Output

#include<stdio.h>
#include<unistd.h>
main()
{

int pid;
printf("Hello");
fork();
if(pid==0)
{
printf("Hello Child process");
}
else
{
printf("Hello Parent Process");
}
}

But your guess might be wrong.......

see the output what i am getting .
Output:
HelloHello Parent ProcessHelloHello Parent Process

can you explain why? i really confused

pixellany 07-06-2010 01:12 PM

Please do not use texting shorthand here: you, your

Do you have the correct syntax and use of brackets for the "if" construct? Please put your code into [CODE] tags so we can see the formatting. (Go to advanced edit mode, select the code, and click the "#")

Tinkster 07-06-2010 01:27 PM

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.


http://www.linuxquestions.org/questi...3/#post4025338


All times are GMT -5. The time now is 03:05 AM.