Mail Archives: djgpp/1997/10/23/22:23:25
Here is something strange I have encountered using DJGPP...
I use this code in C++, where fName is a char* and aName is const char*
fName = new char[strlen(aName)+1];
strncpy( fName, aName, 74 );
I don't want anymore than 74 characters to be displayed when I cprintf(
fName ), because it goes to the text mode screen, so I do this and also put
a zero at fName[74] (if the string length is that long)
It started to overwrite other memory.
I realise what I had done here was bad coding, and I've fixed it up, but I
was curious what was going on here. IS the definition of strncpy in DJGPP to
zero out up to the limit specified, or does it stop at the NULL character? I
thought it was the latter but this example would seem to indicate otherwise.
No urgency in replying, I'm just curious
Brett
--
"Who here believes in telekenesis? Raise MY hand!"
--
Brett Porter
bporter AT rabble DOT uow DOT edu DOT au
http://www.geocities.com/CollegePark/Union/3596
Humour, Programming, and more.
- Raw text -