Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A question about the part of a program

0 views
Skip to first unread message

xiao

unread,
Jul 20, 2008, 5:09:48 PM7/20/08
to
HI~ guys~ I have a question about writing in a file using C. The part
of the code is like this :
How can I print out the value before and after i write it? (I mean
the value of &DataTable) What is more, how these data are orgernized
in the file? Why here is DataTable[i][j][0][0] there?
Thank you very much~

void WriteCloudStats(GRIDDEF *griddef, char *StatsDir, int month, int
year, short ****DataTable)
{

FILE *fptr[2];
int i,j,k,l;
char filename[200],command[250],monstr[5];
GRIDDEF header;

if(month < 10)
sprintf(monstr,"0%d",month);
else
sprintf(monstr,"%d",month);

sprintf(filename,"%s/CldYearlyStats_%d_
%d.dat",StatsDir,month,year);
sprintf(command,"/bin/cp %s %s.arc",filename,filename);
system(command);
fptr[0] = fopen(filename,"w");
sprintf(filename,"%s/CldTotalStats_%d.dat",StatsDir,month);
sprintf(command,"/bin/cp %s %s.arc",filename,filename);
system(command);
fptr[1] = fopen(filename,"w");

for(i=0; i<2; i++){
if(fptr[i] != NULL){
WriteHeader(griddef,fptr[i]);
for(j=0; j<14; j++)fwrite(
&DataTable[i][j][0][0],
sizeof(short),
griddef->NumX*griddef->NumY,
fptr[i]
);
/* printf("Data is %d \n",&DataTable[i][j][0][0]);*/
fclose(fptr[i]);
}
}
}
--
comp.lang.c.moderated - moderation address: cl...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.

0 new messages