看板 C_and_CPP 關於我們 聯絡資訊
在我尚未加上fprintf() 之前開檔似乎很順利,但在使用fprintf(fp,"%lf",AA) 後卻意外的會跳出錯誤訊息@@: 怎麼會這樣呢? ----------------------------------- File:fprintf.c Line:56 Expression: str!=NULL ----------------------------------- 程式碼如下: #include<stdio.h> #include<iostream> using namespace std; int main() { int AA=10; FILE *fp; char mystring[100]; fp=fopen("C:\Test.txt","w"); if(fp== NULL) { printf("error open %s file to write\n"); exit(1); } // 在這加上fprintf()函數就不行了? fprintf()不是stdio.h內的東西嗎@@" fprintf(fp,"%lf",AA); // fclose (fp); system("pause"); return 0; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.37.20.107
TsinTa:我倒是覺得C:\Test.txt很怪,照理說要兩次倒斜線吧 08/16 21:47
tjjh89017:樓上+1,AA是整數...用%lf沒問題嗎? 08/16 21:48
wowrz:嗯哼 我試試 08/16 21:52
wowrz:感謝阿~ 08/16 22:01