Mail Archives: djgpp/1997/08/26/03:02:40
Alexander Bokovoy wrote:
>
> Could somebody explain what is wrong in the next piece of code
> which is successfully compiled from RHIDE but during execution
> breaks with SIGSEGV (if execute from DOS) or SIGABRT (from RHIDE).
> Debugging shows that error occures in the next line:
>
> KeyWord=new char[strlen(keyword)]; // Create and fill key field
>
strlen() returns the length of a string _without_ the null terminating
character. Try changing the line as follows:
KeyWord=new char[strlen(keyword)+1];
And see if it works. BTW, although variable names are case sensitive,
it is less confusing to use names that are spelled differently, rather
than KeyWord and keyword.
-Chris
- Raw text -