qq_37352545
SCNU-HJT
2019-11-26 10:14

新人求助!!为什么输出的结果是乱码

  • c语言
#include<stdio.h>
#include<stdlib.h>
FILE *f1;
int main()
 {
    char ch;
    int i;
    f1=fopen("temp.bin","wb");

    if(f1==NULL)
    {
        printf("文件打开失败\n");
        exit(0);
    }

    for(i=0;i<128;i++)
    {
        fputc(i,f1);
    } 

    fclose(f1);

    f1=fopen("temp.bin","rb");
    if (f1==NULL)
    {
        printf("文件打开失败\n");
        exit(0);
    } 

    while(ch=fgetc(f1)!=EOF)
    {
    putchar(ch);    
    }
    ![图片说明](https://img-ask.csdn.net/upload/201911/26/1574734459_494095.jpg)

    fclose(f1);

  return 0;
 }

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答