http://dspace.dial.pipex.com/town/green/gfd34/art/bloopers.html
The first one seems simple;
return strcpy(malloc(strlen(s)), s);
malloc
could return null
, and strcpy
could try to copy data to memory address 0. Or s could be a pointer to a string (rather than an array), and malloc
would only allocate enough space for a pointer, and would try and copy a string into it. (I think).
What about the second one though?
What a shame that he didn't cast ch to unsigned char when he wrote ch = toupper(ch);
Why should you cast ch
to unsigned char
if you write ch = toUpper(ch);
?