Thread: K&R question

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    17

    K&R question

    On page 176, after declaring the FILE structure, the authors declare an array of 20 FILE structs called _iob and define stdin to be &_iob[0], stdout to be &_iob[1], and &_iob[2] to be stderr. So far so good.

    On page 177, their implementation of the fopen function has the following loop:
    Code:
    for (fp = _iob; fp < _iob + OPEN_MAX; fp++)
        if ((fp->flag & (_READ | _WRITE)) == 0)
            break; /* found free slot */
    The flag member for any of the structs in the array is not initialized, so how is this loop going to work? Thanks in advance.

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    17
    Nevermind, it is there

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. question about K&R example listing 1-6 Arrays
    By fsx in forum C Programming
    Replies: 1
    Last Post: 04-24-2009, 09:32 AM
  2. Question about K&R program
    By Aerie in forum C Programming
    Replies: 15
    Last Post: 04-24-2005, 07:09 AM
  3. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM