0
char option;
FILE *fp;
errno_t err;
err = fopen_s(&fp, "../AVL Trees/input.txt", "r");

while (!feof(fp))
{
    fscanf_s(fp, "%c", &option);   //error is here
    ... 
}

This is for an AVL Trees project. I cannot understand why i have got this error: "not enough arguments passed for format", did i miss something?

Edit:

1>e:\visual studio projects\avl trees\avl trees\main.cpp(27): warning C4473: 'fscanf_s' : not enough arguments passed for format string
1>e:\visual studio projects\avl trees\avl trees\main.cpp(27): note: placeholders and their parameters expect 2 variadic arguments, but 1 were provided
1>e:\visual studio projects\avl trees\avl trees\main.cpp(27): note: the missing variadic argument 2 is required by format string '%c'
1>e:\visual studio projects\avl trees\avl trees\main.cpp(27): note: this argument is used as a buffer size
Gundal
  • 23
  • 3

1 Answers1

0

From the C Standard (K.3.5.3.2 The fscanf_s function)

4 The fscanf_s function is equivalent to fscanf except that the c, s, and [ conversion specifiers apply to a pair of arguments (unless assignment suppression is indicated by a *). The first of these arguments is the same as for fscanf. That argument is immediately followed in the argument list by the second argument, which has type rsize_t and gives the number of elements in the array pointed to by the first argument of the pair. If the first argument points to a scalar object, it is considered to be an array of one element.

So you should use a call like this

fscanf_s(fp, "%c", &option, 1);   
Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335