Wierd Text from File

This is a discussion on Wierd Text from File within the C++ Programming forums, part of the General Programming Boards category; ok I got a new problem after the Dbl Link list was solve. The moving from one node to another ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    17

    Wierd Text from File

    ok I got a new problem after the Dbl Link list was solve.

    The moving from one node to another and back works perfectly.

    now the problem is the information retrieve from the file.
    for example, after I retrieve information form the file into the node when I ask to display the information in the node I got an a bunch of wierd text and the system bleeping.

    however, it only applies to string type. I tried the same returning an integer and displaying on screen and it works fine.

    then I tried setting the string (say fName) to another string and return it, it works fine.

    It only Happens when I try to access the fName, a string, which obtian its information from a file.

    any idea?

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,198
    My guess (as you haven't supplied source code that illustrates your problem) I'm guessing The problem is probably in the code that reads the string from the file. I realise that is not the code exhibiting the problem, but a basic rule is "the cause of a visible problem can be any code that is executed BEFORE or WHEN the problem becomes obvious". Three possibilities I can think of;

    1) If your list has a member which is a pointer to char, you are forgetting to allocate something for the pointer to point at.

    2) You are either overrunning a buffer or forgetting to add a zero terminating character to your string.

    3) You are forgetting to check for end-of-file, and continuing to read past EOF, and therefore inserting garbage into your string (the characters obtained if you continue reading after EOF are unspecified).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 03:49 PM
  5. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM

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