- 论坛徽章:
- 0
|
fscanf and fprintf
我写的是两个程序, 一个用来写文件, 一个用来读
/* 写 INPUT C FILE*/
/* Input variables */
int outNcol;
if ((config_file = fopen (file_name, "w" ) == NULL)
{
printf ("Could not open configuration file : %s\n", file_name);
return 0;
}
fprintf (config_file, "This is SAR data.\n" ;
fprintf (config_file, "---------------------------------------------\n" ;
fprintf (config_file, "Number of samples per line (columes)\n" ;
fprintf (config_file, "%i\n", outNcol);
/*读 OUPUT C FILE */
int Ncol;
if ((config_file = fopen(file_name, "r" ) == NULL)
{
printf("Could not open configuration file : %s\n", file_name);
return 0;
}
fscanf(config_file, "%s\n", Tmp);
fscanf(config_file, "%s\n", Tmp);
fscanf(config_file, "%s\n", Tmp);
fscanf(config_file, "%i\n", &Ncol);
printf("%i\n",Ncol); |
|