Somewhat unexperienced with C here!
I'm using CLion to write a program and keep getting this warning message whenever I use fscanf
to store a value from an input file into a variable:
Clang-Tidy: 'fscanf' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead
I don't understand this error as I thought fscanf
was the function I should be using to read input files? Can someone explain (at a noob level) what's wrong with the way I'm using it?
Here's a sample of my code:
FILE *initial_configuration_box_1_pointer; initial_configuration_box_1_pointer = fopen("initial_configuration_box_1.xyz", "r"); fscanf(initial_configuration_box_1_pointer, "%d\n", &N1); // Warning here. fscanf(initial_configuration_box_1_pointer, "pid\tx\ty\tz\n"); // No warning here. for (i = 1; i <= n1; i++) { fscanf(initial_configuration_box_1_pointer, "p\t%lf\t%lf\t%lf\n", &rx1[i - 1], &ry1[i - 1], &rz1[i - 1]); // Warning here. } fclose(initial_configuration_box_1_pointer);
I'm aware similar questions have been asked, but I couldn't understand any of the (few) answers they got...