#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define LINE_SIZE 256
 
extern FILE *txtfile;
 
//すべての行を表示
void display_all(void){
	char str[LINE_SIZE];       //行保存用の配列
	int i = 1;                 //行番号
 
	while(!feof(txtfile)){
		if(fgets(str, LINE_SIZE - 1, txtfile) == NULL) strcpy(str, "\n");
		if(ferror(txtfile)){
			printf("ファイルの読み込み失敗\n");
			break;
		}
 
		if(!feof(txtfile)) printf("%8d: %s", i, str);
		else{
			if(strcmp(str, "\n") != 0) printf("%8d: %s\n", i, str);
		}
		i++;
	}
 
	return;
}
最終更新:2007年08月01日 08:04