Geeks Talk

Prepare for your Next Interview




printf used along with sleep

This is a discussion on printf used along with sleep within the Unix/Linux forums, part of the Operating Systems category; When I was doing unix programming in C (producer consumer pblm ). I found a strange thing that if 'printf' was used along with 'sleep' then the 'printf' statement wont execute...? ...


Go Back   Geeks Talk > Operating Systems > Unix/Linux

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-08-2007
Junior Member
 
Join Date: Apr 2007
Location: India
Posts: 3
Thanks: 0
Thanked 2 Times in 1 Post
sarith is on a distinguished road
printf used along with sleep

When I was doing unix programming in C (producer consumer pblm ). I found a strange thing that if 'printf' was used along with 'sleep' then the 'printf' statement wont execute...?

Can anybody tell me what is the problem....or
Do these to have any connection with each other..?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-16-2007
Contributing Member
 
Join Date: Jul 2006
Posts: 76
Thanks: 0
Thanked 3 Times in 1 Post
nancyphilips is on a distinguished road
Re: printf used along with sleep

You can very well use printf along with sleep. An example of this usage is given below:

if ((fp=fopen(argv[1], "r+"))==NULL)
{
printf("Error: In reading File!");
sleep(1);
exit(1);
}

The above will print the error as
Error: In reading File!
and wait or delay for 1 second and then exit from the program.

Let me know how you have used so that I can help you more on this.
Reply With Quote
Reply

  Geeks Talk > Operating Systems > Unix/Linux


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Printtextscreen and printf fred C and C++ 1 07-13-2006 09:52 PM
Heard about different forms of printf and scanf joel C and C++ 3 06-29-2006 01:26 PM


All times are GMT -4. The time now is 11:46 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved