I am wondering why Vscode is throwing an error at the line:
char filename[] = scanf("%s", filename);
The error says:
I am wondering why Vscode is throwing an error at the line:
char filename[] = scanf("%s", filename);
The error says:
For starters to use the function scanf
you need to include header <stdio.h>
and the compiler reminds you about this
#include <stdio.h>
The return type of the function scanf
is int
. The function is declared like
int scanf(const char * restrict format, ...);
and the function returns
3 The scanf function returns the value of the macro EOF if an input failure occurs before the first conversion (if any) has completed. Otherwise, the scanf function returns the number of input items assigned, which can be fewer than provided for, or even zero, in the event of an early matching failure.
So this declaration
char filename[] = scanf("%s", filename);
does not make sense.
You need to declare a character array with a fixed number of elements and after that to call the function scanf
as for example
#include <stdio.h>
//...
char filename[20];
scanf("%19s", filename);