くだらない質問はここに書き込め!46
■ このスレッドは過去ログ倉庫に格納されています
0601591
2006/03/05(日) 14:36:36確かに"C:hoge.txt"はおかしかったですね。hoge.txtだけにしておきました。が直りませんね。
fopen()と基本的に同じと聞いて安心しました。全体は無理っぽいので関数を貼ってみます:
void enterData() {
FILE *file_ptr;
flights_record hoge_array[25];
char in_string[10];
int index = 1;
int repeat = TRUE;
char ch;
while(repeat) {
printf("\nFlight ID => ");
gets(hoge_array[index].flightID);
hoge_array[index].recordNumber = index;
printf("Enter more data (Y/N) => ");
ch = toupper(getc(stdin));
putchar(ch);
setbuf(stdin,NULL);
index++;
if(ch != 'Y')
repeat = FALSE;
fflush(stdin);
}
if((file_ptr = fopen("C:hoge.txt","w+")) == NULL) {
printf("Can't open filights file.");
exit(0);
}
fwrite(hoge_array, sizeof(hoge_array), index, file_ptr);
fclose(file_ptr);
}
上のindex++;がやばいという可能性はありますか?
■ このスレッドは過去ログ倉庫に格納されています