i'm try to save a structure containing a integer. when from 0 the integer is changing to 1 all the other positions is also changing what should i do ??
i'm try to save a structure containing a integer. when from 0 the integer is changing to 1 all the other positions is also changing what should i do ??
Well you could post your code so we can see what you're doing.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
imp is set to 1 when function is calledCode:void readbook(booking_type *bookings){ int check =0; int size =0; int i =0; bookings->imp = 1; printf("\n");
Code:fseek(file,sizeof(booking_type)*add,SEEK_SET); fread(&bookings.imp, sizeof(booking_type), 1, file) ; if(bookings.imp == 1) { board[z][y][x] =1; } else{ board[z][y][x] =0; } switch(board[z][y][x]){ case books: printf("X "); break; case notbook: printf("_ "); break; } fflush(file); } printf("\n"); }
I think flushing inputs is undefined.
NOTE: You have too many global variables for me to considered it worth spending my time to help you.
EDIT: You do realize that read/writing (fread/fwrite) to the same file is not always going to work; unless you open the file in binary mode and write only to the end of the file.
Tim S.
Last edited by stahta01; 04-22-2012 at 08:57 AM.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
i need to seek to a position write to that position only and go back to the begining. The main problem of this program is that when im writing to a position its keep on writing to the other position. i need something which stops when the info is written on that posiiton