I'm having trouble when trying to read an integer from a text file:
#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);
}
The first number at "intento1.txt" is 30771
,
but the text written at "bubbletry.txt" is 926363699
.
Could you tell me why that is happening?