[英]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.