Re: Ask for help about the structure
- From: Chad <cdalten@xxxxxxxxx>
- Date: Fri, 18 Jul 2008 12:56:26 -0700 (PDT)
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?
.
- Follow-Ups:
- Re: Ask for help about the structure
- From: Eric Sosman
- Re: Ask for help about the structure
- References:
- Ask for help about the structure
- From: xiao
- Re: Ask for help about the structure
- From: Eric Sosman
- Ask for help about the structure
- Prev by Date: Re: Catching integer overflow
- Next by Date: Re: Moving bytes in memory
- Previous by thread: Re: Ask for help about the structure
- Next by thread: Re: Ask for help about the structure
- Index(es):
Relevant Pages
|