fgetc() and getc()

This is a discussion on fgetc() and getc() within the C Programming forums, part of the General Programming Boards category; int fgetc(FILE *stream); Description Gets character from stream. fgetc returns the next character on the named input stream. Return Value ...

  1. #1
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788

    fgetc() and getc()

    int fgetc(FILE *stream);

    Description

    Gets character from stream.
    fgetc returns the next character on the named input stream.

    Return Value

    On success fgetc returns the character read after converting it to an int without sign extension. On end-of-file or error it returns EOF.
    //----------------------------------------------------------------------------------
    int getc(FILE *stream);

    Description

    Gets character from stream.
    getc returns the next character on the given input stream and increments the stream's file pointer to point to the next character.

    Note: For Win32s or Win32 GUI applications, stdin must be redirected.

    Return Value

    On success, getc returns the character read, after converting it to an int without sign extension.
    On end-of-file or error, it returns EOF.
    //----------------------------------------------------------------------------------

    So, why have both?

  2. #2
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    Found this:

    The getc() function is equivalent to fgetc(), except that if it is implemented as a macro it may evaluate stream more than once, so the argument should never be an expression with side effects.

    So fgetc(*fp++) is not the same as: getc(*fp++)

    It still doesn't answer your question...

  3. #3
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    >> It still doesn't answer your question...

    i'm fully satisfied, thanx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getc stream evaluation
    By terminator in forum C Programming
    Replies: 13
    Last Post: 04-21-2008, 11:42 AM
  2. help with fgetc
    By agentsmith in forum C Programming
    Replies: 3
    Last Post: 04-15-2008, 11:08 AM
  3. About getc and fgetc. Please help.
    By Antigloss in forum C Programming
    Replies: 4
    Last Post: 09-28-2005, 05:00 AM
  4. getc Seg Fault
    By Tyris in forum C Programming
    Replies: 3
    Last Post: 05-25-2005, 01:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21