LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
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: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,962
Blog Entries: 11

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


All times are GMT -5. The time now is 03:40 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration