Results 1 to 2 of 2

Thread: printf used along with sleep

  1. #1
    Junior Member
    Join Date
    Apr 2007
    Answers
    3

    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..?


  2. #2
    Contributing Member
    Join Date
    Jul 2006
    Answers
    76

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact