Thread: Reading text file

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    9

    Question Reading text file

    Hi all,

    I am reading a text file using fgets(). The text file contains paths to different web pages. When I try to print the read string I could see an extra char at the end of the string, I believe that the newline character is copied to the entire string. My question is: How can I get rid of this last character? part of my code looks like this:

    while (!feof(data))
    {
    fgets(strURL, 256, data);
    printf( strURL);
    }
    fclose(data);

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    9
    Never mind I found the answer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. Reading Character at a time from a text file
    By Giania in forum C Programming
    Replies: 8
    Last Post: 02-25-2006, 03:17 PM
  5. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM