How to check if file already has data (in C)? -


i trying write simulation program in c appending file opening in append mode. file csv (comma separated values).

i write headings of simulation information before write actual values don't seem unrelated. there easy way this?

for example:

central node, system delay, bandwidth requirement  14,240,11  4,285,23  13,300,9 

my code looks this:

void data_output(file *fp){ struct stat buf; file fd = *fp; fstat(fd, &buf); fprintf(stderr,"debug------%d\n",buf.st_size); } 

the output error is:

ff.c: in function ‘data_output’: ff.c:296:2: error: incompatible type argument 1 of ‘fstat’ fstat(fd, &buf); ^ in file included /usr/include/stdio.h:29:0,              ff.c:1: /usr/include/sys/stat.h:148:5: note: expected ‘int’ argument of type ‘file’  int _exfun(fstat,( int __fd, struct stat *__sbuf ));  ^ makefile:7: recipe target 'ff.o' failed make: *** [ff.o] error 1 

what doing wrong? should typecasting in order make work?

you can check size of file. more info how size can check check post


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -