I was curious to know why the following code snippet works in some C compilers and not others. My professor can compile this code in DevC++ and so can I, but I can not compile this code in VS 2010. Any ideas? VS says a.word has a bad pointer. I assume VS is mad because I haven't initialized a.word, but why does the code compile and work in DevC++? I have to add a.word=""; before the strcpy and then it works in VS, but again I am curious to know why. Thanks
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct foo{ int num;
char* word;
struct foo *ptr;};
int main() {
struct foo a;
a.num = 5; a.ptr = &a;
strcpy(a.word,"whichword");
}