![](/img/trans.png)
[英]Unable to start program, cannot find the file specified, Visual Studio 11
[英]Visual Studio Error “Unable to start program: The system cannot find the specified file.”
我正在处理一个项目,并且根本无法让 Visual Studio 2019 访问任何输入/输出文件。 我使用了网上找到的示例代码和模板,但仍然没有找到任何运气,并继续收到“无法启动程序,系统找不到指定文件”的错误。
我使用 Window 桌面向导创建了一个新项目,并创建了一个“main.c”源文件,正如我的教授指示我们为其他 C 编程作业所做的那样。 正如一些指南所建议的那样,我已经尝试过构建>构建解决方案并将.txt更改为内容(在属性下)的“是”,但上述方法似乎都无法解决问题! 这是我一直试图用作参考的示例代码(不是我自己的)! 任何帮助表示赞赏!
#include <stdio.h>
int main()
{
/* Pointer to the file */
FILE* fp1;
/* Character variable to read the content of file */
char c;
/* Opening a file in r mode*/
fp1 = fopen("newfile.txt", "r" );
/* Infinite loop –I have used break to come out of the loop*/
while (1)
{
c = fgetc(fp1);
if (c == EOF)
break;
else
printf("%c", c);
}
fclose(fp1);
return 0;
}
确保您在与源代码文件相同的目录中有“newfile.txt”。替代解决方案是将读取模式更改为写入模式,以便编译器将创建一个文件(如果不存在)代码应该是像这样-
fp1 = fopen("newfile.txt", "w" );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.