相关疑难解决方法(0)

而((c = getc(file))!= EOF)循环不会停止执行

我无法弄清楚为什么我的while循环不起作用.代码在没有它的情况下正常工作......代码的目的是在bin文件中查找秘密消息.所以我得到了代码来查找字母,但现在当我尝试将其循环到文件末尾时,它不起作用.我是新来的.我究竟做错了什么?

main(){

FILE* message;
int i, start;
long int size;
char keep[1];

message = fopen("c:\\myFiles\\Message.dat", "rb");

if(message == NULL){
    printf("There was a problem reading the file. \n");
    exit(-1);
}

//the first 4 bytes contain an int that tells how many subsequent bytes you can throw away
fread(&start, sizeof(int), 1, message);
printf("%i \n", start); //#of first 4 bytes was 280
fseek(message, start, SEEK_CUR); //skip 280 bytes
keep[0] = fgetc(message); //get next character, keep it
printf("%c", keep[0]); //print character

while( (keep[0] = …
Run Code Online (Sandbox Code Playgroud)

c file input output

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

c ×1

file ×1

input ×1

output ×1