Unable to locate the Bug
- by tzenes
I was recently on The Daily WTF when I came across this old post. In it the author mentions that one of the programmers changed this code:
int main (int argc, char **argv)
{
int x;
char data_string[15];
...
x = 2;
strcpy(data_string,"data data data");
...
}
To this code:
int main (int argc, char **argv)
{
int x = 2;
char data_string[15] = "data data data";
...
}
The author goes on to mention:
[the coder] changed every single variable to be initiated on the stack
For the life of me I cannot see how this change could be harmful, and I am worried that it is a lapse in my C knowledge. What is the WTF?