I encountered some code as follows:
char *buff; // a charpointer
if (some condition)
buff = &ch; // sets BUFF to the address of ch
strcpy(buff, oldbuff); // assume OLDBUFF contains valid string
..and then a bit later on...
if strcmp(buff, "ABC")
In the case where buff was set to &ch, I am very suspicous
of the above strcmp. Since buff points to a single CHARACTER,
rather than a string, I think it's asking for trouble.
Not to mention that ch is also unitialized, but even if ch
WERE initialized, I still object to the strcmp().
Would anyone agree that the above code is flawed?