Thread: Basic text file encoder

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Quote Originally Posted by ulillillia View Post
    For one, you should avoid using EOF to control loops - read the FAQ for more details.
    No you shouldn't, you should only avoid using feof() (feof checks a flag) to control loops, EOF is perfectly fine.
    Quote Originally Posted by Abda92
    Code:
    char c;
    
    c = getc(file);
    while (c != EOF)			/* there is still something to input */
    EOF doesn't fit into a char, also fgetc() returns a signed integer.

    Code:
    int c;
    while((c = fgetc(file)) != EOF)
    {
         /* blah... */
    Last edited by zacs7; 05-22-2007 at 05:05 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. checking values in a text file
    By darfader in forum C Programming
    Replies: 2
    Last Post: 09-24-2003, 02:13 AM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM