1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

quries

Discussion in 'C' started by answerme, May 21, 2008.

  1. answerme

    answerme New Member

    Joined:
    Dec 17, 2007
    Messages:
    114
    Likes Received:
    0
    Trophy Points:
    0
    I have 2 queries
    1. what this line means which is in bold
    2.Up to how many times it will loop back
    Code:
    main()
    {
    int c ;
    int count=0 ;
    
    [B]while ( ( c = getchar() ) != EOF )[/B]
       count ++ ;
    
    printf( "%d characters\n" , count );
    }
     
  2. mr.anandc

    mr.anandc New Member

    Joined:
    May 6, 2008
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    0
    1. what this line means which is in bold
    while ( ( c = getchar() ) != EOF )

    In this line, first getchar waits to for input from user and then the iput is assigned to "c ", and "c" value is compared against EOF.

    2.Up to how many times it will loop back
    In windows, getchar returns EOF when the iput is (ctrl + z). So it loop backs until (ctrl + z) is entered.

    So, count prints, number of characters read so far.
     

Share This Page