The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Solving the network storage dilemma - Builder AU iBot UNIX and Linux RSS News 0 08-12-2007 10:40 PM
Disabling 802.3x flow control LivinFree IP Networking 0 11-18-2006 02:33 AM
Flow Chart sabari High Level Programming 1 04-12-2006 02:57 AM
A Terminal Dilemma rocky_triton UNIX for Dummies Questions & Answers 5 04-13-2005 12:32 PM
how to assign correct control flow? apalex UNIX for Dummies Questions & Answers 1 07-11-2001 12:10 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-10-2006
tej.buch tej.buch is offline
Registered User
  
 

Join Date: Jan 2006
Location: Gandhinagar, India
Posts: 25
dilemma in control flow

hello im facing a queer problem when i execute the foll code in unix


Code:
# include <stdio.h>
# include <unistd.h>

main(int argc,char *argv[])
{
	FILE *fp = fopen("/ras/chirag/fifotest/file.fifo","a");
	int i=1;
	fprintf(fp,argv[1]);
	printf("I SLEEP");
	system("date");
	for (i=0;i<50;i++)
	{
	//printf("do nothing\n");
	}
	i=sleep(25);
	printf("%d",i);
	printf("I WAKE UP");
	system("date");
	fclose(fp);
}

the above code first executes the date command and then sleeps for 25 secs and then prints the strings "I SLEEP" and "I WAKE UP" in the end...

the output i obtained is:

Code:
Fri Feb 10 19:10:16 CST 2006
Fri Feb 10 19:10:41 CST 2006
I SLEEP0I WAKE UP


can anyone help me why is such a flow occuring and what can be done to get it the normal way? thanks in advance............
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes 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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0