1

Im trying to read an URL from a file like this

ID 0
FILE ".\\Models\\Woman2.nfg"

And save it into a char tempURL[80] the line im having trouble with is the second one.

fscanf_s(mFile, "ID %d", &TempId);
fscanf_s(mFile, "%*s %s", tempURL);

the first line works fine, but the second one crashes the program What am I doing wrong?

Thanks

1 Answers1

2

fscanf_s is MS's "safe" fscanf. It requires you to pass the size of the data:

fscanf_s(mFile, "%*s %s", tempURL, 80);

The reason yours compiles without a warning about missing arguments is that fscanf_s accepts a variable number of arguments and the compiler cannot tell if you've passed enough.

001
  • 13,291
  • 5
  • 35
  • 66