Problem with doing data logging

Hi,

I would like to write the data from the sensors to a file after booting from the CF card. However, after executing the prgraming, when I open the file, it is empty.

I have checked that the file is opened correctly, the number of bytes writen is correct and that the file is closed. When i open the file on the host(desktop), the file is empty and the last edited time is that at which I created the file in the host. This means that the data is not saved when the cf card is in the PC/104 CPU.

What could be the problem?

Would appreciate very much your help.

The simple code is below:

#include
#include <stdio.h>
#include <time.h>
#include <sys/syspage.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/types.h>

int main(int argc, char *argv[]) {
int i=0,k=0;
FILE *data;
//int data;

int errvalue;
int check;
errno = EOK;

data = fopen(“file.txt”,“w”);

if(data!=NULL){

printf("file is opened = ");
errvalue = errno;
printf(“error is %d\n”,errvalue);
printf(“means : %s\n”, strerror(errvalue));

fprintf(data,"OK");
errvalue = errno;
printf("error is %d ",errvalue);
printf("means : %s\n", strerror(errvalue));

printf(“trying to close file =”);
check = fclose(data);

if(check!=0){
errvalue = errno;
printf("error in closing file :%d ",errvalue);
printf(“means : %s\n”, strerror(errvalue));
}

else
printf(“file is closed\n”);
}
else
printf(“file is not opened\n”);

return 0;
}