私はDev-C++ IDEを使用していますが、今はファイル処理をしようとしています.hereは私のコードです:
int main(){
FILE *fp;
int b = 10;
int f;
fp = fopen("data.txt", "w");
//checking if the file exist
if(fp == NULL){
printf("File does not exist,please check!\n");
}else{
printf("we are connected to the file!\n");
}
fprintf (fp, " %d ", b) ;
fclose(fp);
printf("Reading from the file \n");
FILE *fr;
fr=fopen("data.txt","r");
fscanf (fr, " %d ", &f) ;
fclose(fr);
printf("the data from the file %d \n", f);
return 0;
}
このコードは NetBeans では機能しますが、Dev-C++ では「ファイルに接続されています」というメッセージが表示されますが、値「10」がファイルに入力されません。答えを教えてください、どうすればいいですか?