T
tfelb
You know that goto's required by doped silicon are pretty good smokes
Hmm I did what someone said..I coded a strpad function with the
parameters (oldstring, newLen, given character) (make the orginal
string bigger (the newLen is now the len of the new string), copy the
old string into /new/ string and fill the rest with '.' chars.
But a heap corruption takes place?
1. In the function strpad, I terminate the new string with '\0'. Maybe
thats the cause?
One solution for the problem I guess is if i set p after the printf
call to NULL ( p = NULL )
int main(int argc, char **argv)
{
char text[] = "This is a test sentence);
char *p = strpad(text,30,'.');
if(p)
{
printf("%s",p);
free(p); / cause a memory heap corruption ? */
}
}- Zitierten Text ausblenden -
- Zitierten Text anzeigen -
Oh I see a typo. The corrected version is
int main(int argc, char **argv)
{
char text[] = "This is a test sentence";
char *p = strpad(text,30,'.');
if(p)
{
printf("%s",p);
free(p); / cause a memory heap corruption ? */
}
}