Thread: string problem

  1. #1
    Registered User
    Join Date
    Jan 2006

    string problem

    I have an issue with the file reading.

    for example ,we have a set of cards but before it, there is an int like:

    king of clubs
    six of clubs
    four of diamonds
    six of hearts
    four of hearts

    If I use fgets and fputs to read and print the file, what can I do so that I star reading and print from the second line( skip the line with 12)

    I called each line LINE and set a while loop

    while( 1 ) {/*while begins*/
    fgets(LINE, sizeof(LINE), fin);
    if ( feof(fin) ) /* check for EOF right after fgets() */
    fputs(LINE, fout);}
    I dont succeed to skip the first line I tried LINE+1 but it is an horizontal displacement..
    Can I have some suuggestions?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    fgets( line, sizeof line, fin ); /* ignore the first line */
    while( fgets( line, sizeof line, fin ) != NULL )
        fputs( line, fout );
    Nice and clean, without all the crap.

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  2. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  3. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  4. Compile Error that i dont understand
    By bobthebullet990 in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2006, 09:19 AM
  5. Replies: 4
    Last Post: 03-03-2006, 02:11 AM