Re: problems with char * return from a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eus wrote:
It looks like that you have not zeroed your `a'.
`a[0]='\0';' is not enough.
Either you do `char a[BUFFER_SIZE] = {0};' when defining `a' or, better, you do `memset(a, 0, BUFFER_SIZE);'
That answer is incorrect. strcpy copies the terminating null, so you don't need to. Depending on how a was declared/allocated your suggestions might just be useless or they might be harmful.

I don't know the answer to the original question. The answer is in some part of the code that was not included. Maybe the problem is in the way a was declared/allocated. Maybe the copy into gave the perfectly correct result and the problem was in the way a was printed.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux