GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-May-2004, 10:18
fj8283888 fj8283888 is offline
Junior Member
 
Join Date: Apr 2004
Posts: 37
fj8283888 is on a distinguished road

fork() questions


Code:
#include <stdio.h> #include <signal.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> main() { int c, m; pid_t cpid; while ( '#' != ( c = getchar()) ) putchar(c); putchar('\n'); fflush(stdout); if ( cpid = fork() ) { if ( cpid != wait(&m) ) { printf("Error unknown child\n"); exit(1); } while ( '?'!= ( c = getchar()) && c != EOF ) putchar(c); putchar('\n'); fflush(stdout); exit(0); } else { while ( '#' != ( c = getchar()) ) putchar(c); putchar('\n'); fflush(stdout); exit(0); } }
I got some problems from this program
Logic from this program:
when a user typed a string, at the end it needs to contain a # sym to finish the line. Examples:
sfsdffs#
it should return as:
sfsdffs#
sfsdffs
the program was sucessful to do two times,
in third time, it showed as following:
sfsdfsaf#
sfsdfsaf# (# should not appear)

to finish the program, simply type ? to finish.

Thanks.
Frenk
 
 

Recent GIDBlogToyota - 2008 November Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple questions? Netizen Dave Apache Web Server Forum 3 17-Mar-2004 05:45
[Linux] Top newbie questions. JdS Computer Software Forum - Linux 3 22-Jan-2004 13:00
questions about ram instalation cpu-loser Computer Hardware Forum 3 25-Oct-2003 06:08
newbie with stupid questions JUNK KED MySQL / PHP Forum 1 16-Oct-2003 09:58
Where do I go now? - Questions about PHP, and etc. PerfectMercy MySQL / PHP Forum 7 11-Sep-2003 06:03

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:17.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.