User Profile

Collapse

Profile Sidebar

Collapse
codeGhost
codeGhost
Last Activity: Nov 17 '08, 12:35 AM
Joined: Nov 15 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • codeGhost
    replied to C++ (char *) initialization issues
    in C
    Alright! Fixed!

    The answer was the null-terminator at the end. It turns out that when I created the char * pointer, the program was assigning garbage from the heap?, or from somewhere, and continued assigning garbage until it ran into its own '\0.' In any case, assigning a null pointer to the end of the char * fixed the problem!

    In short: If you're getting a character pointer array that is longer than you expect it...
    See more | Go to post

    Leave a comment:


  • codeGhost
    replied to C++ (char *) initialization issues
    in C
    Hmmm. I had read something about 'null-terminated,' but hadn't made the connection. I'll add that to my code and see what happens.

    @oler1s: I actually did use strlen because I didn't want to actually count the number of characters that showed up. I first noticed the problem when I output the character sequence to the command prompt and got a bunch of garbage on the end of what I expected.

    As an additional note,...
    See more | Go to post

    Leave a comment:


  • codeGhost
    started a topic C++ (char *) initialization issues
    in C

    C++ (char *) initialization issues

    I've been trying to ignore this issue for a while now, but I've come to the point in my code where I can't do so anymore. (For those of you who are wondering, this is NOT a homework question).

    Platform: VC++ 2002
    System: Windows XP, sp3

    ::First, here's the code in question::

    Code:
    char * cSection (const char* data, int start, int finish)
    {
    if (start >= 0 && finish >=
    ...
    See more | Go to post
No activity results to display
Show More
Working...