作者beboy (??)
看板C_and_CPP
標題[問題] fscanf的問題
時間Fri Jul 24 17:31:24 2009
這問題困擾我很久了
本來以下這語法在Visual Studio 2003 可用
可以一到Visual Stusio 2005 complier就會出現中斷的訊息
FILE *fp1=fopen("H_real_64.txt","r");
int m;
double temp_value,H_real[64];
for(m=0;m<64;m++)
{
fscanf(fp1,"%lf",&temp_value);
H_real[m] = temp_value;
}
這程式碼的目的是要把.txt檔裡頭的double形式的數字讀進來
找很久都不知道到底發生什麼問題
有經驗的各位版友能幫我解答一下嗎,謝謝哦~
錯誤的訊息如下 :
Debug Assertion Failed!
Program:...
File:fscanf.c
Line:52
Expression:(stream!=NULL)
for information on how your program can cause an assertion failture, see the
Visual C++ documentation on asserts.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.41.186
※ 編輯: beboy 來自: 140.112.41.186 (07/24 17:34)
1F:推 VictorTom:除了建議先check fp1有沒有正確開出檔案外, 看不出問題. 07/24 17:38
2F:→ VictorTom:建議把有什麼error中斷貼上訊息吧....:) 07/24 17:38
※ 編輯: beboy 來自: 140.112.41.186 (07/24 17:43)
3F:推 barriertw:我猜不是語法的問題,而是 H_real_64.txt 沒有備妥 ... 07/24 17:49
4F:推 ledia:就是開檔失敗 07/24 18:01
5F:→ beboy:問題已解決了~就是2003和2005檔案放的位置是不一樣的~"~||| 07/24 18:02
6F:→ beboy:感謝大家幫忙^^ 07/24 18:02