c - “函数调用中的参数太少”(Visual Studio)。我无法打开文件。如何解决这个问题?
问题描述
“函数调用中的参数太少”(Visual Studio)。我无法打开文件。如何解决这个问题?
#include <stdio.h>
int main() {
FILE * fp;
fp = fopen_s("testfile.txt", "w"); //to open file
return 0;
}
解决方案
Too few arguments in function call
意味着您调用了一个fopen_s
带有 2 个参数的函数(在这种情况下),但该函数需要 3 个参数。
怎么解决?只需搜索并阅读. fopen_s()
通常,也有使用示例。
阅读文档后,您会发现这是您的使用方式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;
}
...
}
推荐阅读
- javascript - 获取 JavaScript 中剩余的月数、周数和天数
- javascript - PHP根据点击的锚点获取文件
- javascript - 使用制表器对多个表使用相同的数据
- ios - 首次呈现时 tableView 不会滚动到底部
- vb.net - 使png图像透明
- java - BottomNavigationView 没有动画
- java - 在 Spring Boot 中加载 schema.sql 文件时出现 SQL 语法错误
- cmake - cmake 中的 AUTHOR_WARNING 消息是什么?
- ubuntu - 终结者 1.91 使用 gtk3 css 更改选项卡主题/颜色
- typescript - NestJS - 如何使用 @Body() 装饰器访问帖子正文?