[問題] 開關檔案問題

看板C_and_CPP (C/C++)作者 (哈哈哈)時間13年前 (2012/08/16 21:41), 編輯推噓0(004)
留言4則, 3人參與, 最新討論串1/1
在我尚未加上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

08/16 21:47, , 1F
我倒是覺得C:\Test.txt很怪,照理說要兩次倒斜線吧
08/16 21:47, 1F

08/16 21:48, , 2F
樓上+1,AA是整數...用%lf沒問題嗎?
08/16 21:48, 2F

08/16 21:52, , 3F
嗯哼 我試試
08/16 21:52, 3F

08/16 22:01, , 4F
感謝阿~
08/16 22:01, 4F
文章代碼(AID): #1GBFY0hf (C_and_CPP)
文章代碼(AID): #1GBFY0hf (C_and_CPP)