Re: Ask for help about the structure



On Jul 18, 10:04 am, Eric Sosman <Eric.Sos...@xxxxxxx> wrote:
xiao wrote:
Can anyone help me to find out what are the structure of 'DataTable' ?
Does loop the 14 layers or the 800*800 array first?
(NumX=NumY=800)
gridde and WriteHeader are two structures
Thank you~~~ :)

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

     Bad ASCII art:

        short****  short***  short**    short*       short

        DataTable -> [0]
                     [1] -> [1][0]
                     ...    [1][1] -> [1][1][0]
                              ...     [1][1][1] -> [1][1][1][0]
                                         ...       [1][1][1][1]
                                                        ...

{

     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(monstr, "%02d", month);' is easier.  (Easier still:
leave it out altogether, since `monstr' is never used.)

     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");

     You'd better hope that nothing goes wrong with either of
the cp commands, or you could wipe out the old data ...  Since
you don't actually need the original copies (you overwrite them
immediately), why not just use the rename() function to change
the existing files' names?  The benefit is that you can check
whether rename() succeeded or failed; there's no portable way
to do so with system().


Maybe I'm not looking at it close enough, but how do you figure that a
failure with either cp could possibly wipe out the old data?
.



Relevant Pages