H
haloman
Why does:
char *myString = (char *) malloc(WORDLIMIT*sizeof(char));
fscanf(openFile, "%s", myString) != EOF;
work yet
char *myString = (char *) malloc(WORDLIMIT*sizeof(char));
fscanf(openFile, "%s", &myString) != EOF;
doesn't (crashes, doesn't result in a compiler error)? I thought the
prior was incorrect, and the latter correct.
Many thanks.
P.S. Yes, I know I shouldn't be using fscanf like this, there are
buffer overflow problems and that I probably should be shot already,
but that's not the question being asked
char *myString = (char *) malloc(WORDLIMIT*sizeof(char));
fscanf(openFile, "%s", myString) != EOF;
work yet
char *myString = (char *) malloc(WORDLIMIT*sizeof(char));
fscanf(openFile, "%s", &myString) != EOF;
doesn't (crashes, doesn't result in a compiler error)? I thought the
prior was incorrect, and the latter correct.
Many thanks.
P.S. Yes, I know I shouldn't be using fscanf like this, there are
buffer overflow problems and that I probably should be shot already,
but that's not the question being asked