Apparently fscanf_s() needs a size parameter after the variable address
fscanf_s(fp, "%c;%d-%d\n", &axis, 1, &minSpeed, &maxSpeed);
But I suggest you not use *_s functions: they are worse than explicitly named functions. They require the same checks and make you feel safe when you do not. I suggest you not use them because of the false sense of security and the fact that they are not available in many implementations, and your programs work only in a limited subset of the possible machines.
Use plain fscanf ()
fscanf(fp, "%c;%d-%d\n", &axis, &minSpeed, &maxSpeed); /* fscanf(fp, "%1c;%d-%d\n", &axis, &minSpeed, &maxSpeed); */ /* default 1 ^^^ same as for fscanf_s */
And your use of feof() is wrong.
fscanf() returns EOF when there is an error (end of file or match with error or read error ...).
You can use feof() to determine why fscanf() failed, and not to check if it fscanf() on the next call.
while (1) { chk = fscanf(); if (chk == EOF) break; if (chk < NUMBER_OF_EXPECTED_CONVERSIONS) { } else { } } if (feof()) ; if (ferror()) ;
source share