'too few argument in function call' (visual studio). i cant open the file. How to solve this?
#include <stdio.h>
int main() {
FILE * fp;
fp = fopen_s("testfile.txt", "w"); //to open file
return 0;
}
'too few argument in function call' (visual studio). i cant open the file. How to solve this?
#include <stdio.h>
int main() {
FILE * fp;
fp = fopen_s("testfile.txt", "w"); //to open file
return 0;
}
Too few arguments in function call
means that you called a function (fopen_s
in this case) with 2 arguments, but the function requires 3 arguments.
How to solve? Simply search and read the documentation for fopen_s()
. Often enough, there are also examples of usage.
After reading the docs, you will find out that this is how you use fopen_s()
:
int main(void) {
FILE* fp = NULL;
if (fopen_s(&fp, "testfile.txt", "w") != 0 || fp == NULL) {
printf("ERROR: cannot open file\n");
return EXIT_FAILURE;
}
...
}