CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 1999
    Posts
    14

    trailing characters on newly initialized character arrays

    So I'm doing some file I/O and when i initialize a character array of a given size, a bunch of nonsense characters (like ýýýýÝÝÝÝÝÝÝÝÝÝÝA) is appended IN ADDITION to all of the characters i want. Do you think it has something to do w/ the placement of the array in memory? I'm first declaring the pointer, then assigning a size a couple lines later:

    char *InString;
    InString = new char[FileLength];

    where FileLength is an integer. It's really weird, and i've verified it w/ the debugger. Immediately when it is initialized it is given "FileLength" spaces, PLUS a few more for the nonsense characters. Any help would be GREATLY appreciated.


  2. #2
    Join Date
    Apr 1999
    Posts
    23

    Re: trailing characters on newly initialized character arrays

    Hi,

    The ýýý... is an indication that the memory allocated by the keyword new is exceeded. You do not have to worry about that coz you will not be writing to those locations (if you are doing it correctly).

    Chao


  3. #3
    Join Date
    May 1999
    Location
    OR, USA
    Posts
    65

    Re: trailing characters on newly initialized character arrays

    Make sure u terminate the string with a null char.
    Don't worry about those garbage chars.



  4. #4
    Join Date
    Jun 1999
    Posts
    14

    Re: trailing characters on newly initialized character arrays

    THANK YOU!!!


    I didn't even think of the null char at the end of strings. The CString conversion now stops reading when it hits the null. I appreciate it.




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured