LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 07-06-2010, 01:06 PM   #1
vivignesh
LQ Newbie
 
Registered: Jul 2010
Posts: 18

Rep: Reputation: 0
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

Last edited by vivignesh; 07-06-2010 at 01:19 PM.
 
Old 07-06-2010, 01:12 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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 "#")
 
Old 07-06-2010, 01:27 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
  


Closed Thread

Tags
fork, program



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Output of the C program? thelink123 Programming 8 06-09-2009 11:08 PM
How to pass the output of one program to another program without backticks? BrianK Linux - General 4 11-11-2008 06:27 PM
I Have A Game For You Guess That Program!!!! op_stager General 15 09-28-2004 12:50 AM
C function to execute a program and return the output of the program ryan.n Programming 4 08-14-2004 10:11 PM
How do I save the output from a program? Fe98 Programming 4 11-10-2003 09:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration