OpenGrADS2.1.a2-气象家园整合版.7z
OpenGrADS2.1.a2-气象家园整合版.7z,可用于画图,读取文件等
代码片段和文件信息
#include
#include
#include
#include
#define MAX_BUF 1024
main (int argc char *argv[])
{
int line i iflag;
char buf[MAX_BUF];
char tokbuf[MAX_BUF]; /* copy of buf[] for strtok() to work on */
int f x y scale ref dw;
char *valp;
char* units;
char* description;
char file_in[70] file_out[70];
FILE *fp_in *fp_out;
if ( argc != 2 )
{
printf(“ ERROR: no arguments
“);
printf(“ convert “);
exit(-1);
}
sprintf(file_in“%s.old“argv[1]);
printf(“ full input file name =%s
“ file_in);
sprintf(file_out“%s“argv[1]);
printf(“ full output file name =%s
“ file_out);
sprintf(buf “mv %s %s.old
“ argv[1] argv[1]);
system(buf);
if( (fp_in = fopen( file_in “r“ )) == NULL )
{
sprintf( buf “Can‘t open input file “%s“
“ file_in );
exit(1);
}
if( (fp_out = fopen( file_out “w“ )) == NULL )
{
sprintf( buf “Can‘t open output file “%s“
“ file_in );
exit(1);
}
for( line=1; fgets( buf MAX_BUF fp_in ) != NULL; line++ )
{
iflag = 0;
valp = buf;
if( *valp == ‘#‘)
{
fprintf(fp_out“%s“ buf);
} else if ( strlen(buf) == 1 ) {
fprintf(fp_out“
“);
}else{
/*
* Since strtok() mangles the string it works on let strtok() use
* a copy of buf.
*/
strcpy( tokbuf buf );
/*
* Trim trailing whitespace in ‘tokbuf‘ (this makes it easier
* to get the description later on).
*/
/* 092997 LAH: Added char cast to correct Linux warning */
/* 100997 LAH: Added ulong_t cast */
for( valp=&tokbuf[strlen(tokbuf)-1]; isspace( *valp ); valp-- )
*valp = (char) NULL;
/* Get F X and Y portion and compute table location */
if( (valp = strtok( tokbuf “ - “ )) == NULL )
{
printf(“Line %d: Missing F descriptor
“ line);
iflag = 1;
}
else
f = atoi( valp );
if (iflag == 0)
{
if( (valp = strtok( NULL “ - “ )) == NULL )
{
printf(“Line %d: Missing X descriptor
“ line);
iflag =1;
}
else
x = atoi( valp );
}
if ( iflag == 0)
{
if( (valp = strtok( NULL “ “ )) == NULL )
{
printf(“%Line %d: Missing Y descriptor
“ line);
iflag = 1;
}
else
y = atoi( valp );
}
/* Check for descriptor duplication. */
if (iflag == 0 )
{
if( (valp = strtok( NULL “ “ )) == NULL )
{
printf(“Line %d: Missing Scale value
“ line);
} else
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)