Code: #include <conio.h> #include <stdio.h> #include <string.h> typedef struct { char surname[20]; double somenumber; }personnel; personnel jack; int main() { FILE *stream; jack.somenumber=87021506119; //Here I changed the first time the value strcpy(jack.surname,"Mcgyver"); stream=fopen("c:\\personnel.txt","wt"); fprintf(stream,"%s\t%0.lf",jack.surname,jack.somenumber); fclose(stream); jack.somenumber=87021506000; // Here I changed the second time the value stream=fopen("c:\\personnel.txt","rt"); fscanf(stream,"%s\t%0.lf",jack.surname,&jack.somenumber); fclose(stream); printf("%s\t%.0f",jack.surname,jack.somenumber); //Here I get '87021506000' and this is not the value that should be here :/ getch(); } I really don't know why it's not working...... Please HELP me !
You need to learn how to post a question. Since we're only mind readers on the second Tuesday of each week, you should TELL us things. How is it not working? How is it not meeting your expectations? Do you have compiler errors? Do you have run-time errors? What is your OS? Your implementation? Your compiler? On what lines to the errors, if any, occur? That said, let me ask YOU a question. Why are you using C library functions in C++? Even if they work? Bite the bullet. Get off the fence. Write C or write C++. Just make up your mind. That said, also, I have not looked at your code. I'm sure I could figure out what is wrong, if I spent the time. I don't want to spend the time if YOU don't want to spend the time. Fair enough?