嗨,我有一個非常令人沮喪的問題,指針可能有人讓我知道我在這裏做錯了什麼。 感謝FREAD C指針問題
// This functions reads from the file
void get__data_block_from_disk(char* ptr, int block_num){
int file_desc;
int x;
open_fs(file_path);
file_desc = fileno(fileptr);
x = lseek(file_desc, DATA_BLOCK_OFFSET + block_num*BLOCK_SIZE, SEEK_SET);
fread(&ptr, BLOCK_SIZE, 1, fileptr);
close_fs();
}
// This function writes to the file
void place__data_block_into_disk(char* ptr, int block_num){
int file_desc;
int x;
printf("char in place: %c\n", ptr);
open_fs(file_path);
file_desc = fileno(fileptr);
x = lseek(file_desc, DATA_BLOCK_OFFSET + block_num*BLOCK_SIZE, SEEK_SET);
fwrite(ptr, BLOCK_SIZE, 1, fileptr);
close_fs();
}
你預計會發生什麼,你會得到什麼? – 2011-04-22 21:14:08