看板 C_and_CPP 關於我們 聯絡資訊
#include <stdio.h> #include <stdlib.h> #include <iostream.h> #include <conio.h> void main(void) { FILE *fp_2; int bit,num,out=0; char file_name_2[20]=""; char h_1[15]; printf("file name_2:");//霍夫曼表 scanf("%s",file_name_2); if((fp_2=fopen(file_name_2,"r"))==NULL) { printf("test file name error!!\n"); exit(1); } while(!feof(fp_2)){ fscanf(fp_2,"%d%d%s",bit,num,h_1); cout<<h_1<<endl; } fclose(fp_2); } 我想將一個txt檔讀入,並將其內容一一輸出,我用!feof(fp_2)來判斷是否已全部輸出 完畢,我編譯及link都有過但執行程式時會出現該程式出現問題必需關閉的訊息,我想 請問我的程式到底問題出在哪,請各位大大賜教。 以下是我.txt檔的內容: 0 2 00 1 3 010 2 3 011 3 3 100 4 3 101 5 3 110 6 4 1110 7 5 11110 8 6 111110 9 7 1111110 10 8 11111110 11 9 111111110 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.42.219.246
windincloud:int fscanf(FILE* stream, const char* format,...) 04/30 10:25
windincloud:int scanf( const char *format, ... ); 04/30 10:26
windincloud:主要是掛在fscanf() 04/30 10:28
hardman1110:tnanks a lot^^ 04/30 13:22