のファイルを読み込むときセグメンテーションフォールトC
int textdump(const char *filename)
{
int count = 0;
FILE *file;
file = fopen(filename,"r");
char letter;
while(!feof(file)) {
letter = fgetc(file);
if (isprint(letter)) {
printf("%c",letter);
count++;
}
else {
printf("?");
}
}
fclose(file);
return count;
}
[fgetc](https://linux.die.net/man/3/fgetc)は、 'int'を再実行します – LPs
' while(!feof( ')はアンチパターンであり、常に間違っています。 – unwind
!あなたが実際にあなたがそのコードでセグメンテーション違反を得ることができる唯一の方法だ(!ファイル= NULL) ' – LPs