小编Fra*_*ijo的帖子

从C中的文件读取整数时遇到麻烦

我在尝试从文本文件中读取整数时遇到了麻烦:

#include <stdio.h>
#include <string.h>

int main()
{  
    int op;

    /* Open file for both reading and writing */
    FILE *d = fopen("intento1.txt", "r");
    FILE *f = fopen("bubbletry.txt", "w+");

    /* Read and display data */
    fread(&op, 4, 1, d);

    printf("%d\n", &op);
    fclose(d);
    /* Write data to the file */
    fprintf(f,"%d\n",&op);

    fclose(f);

    return(0);
}
Run Code Online (Sandbox Code Playgroud)

"intento1.txt"中的第一个数字是30771,但写在"bubbletry.txt"的文本是926363699.你能告诉我为什么会这样吗?

c printf fread

-1
推荐指数
1
解决办法
64
查看次数

标签 统计

c ×1

fread ×1

printf ×1