Thanks Mr Bianruichao.
#include <stdio.h>
#include <math.h>
int main()
{
char filename[500] = { 0 };
char buff[500] = { 0 };
for (int num = 1; num < 100; num++)
{
sprintf(filename, “C:\Users\wangchaoran\Desktop\single_path_record(4)\single_path_record\path_record_num_%d.txt”, num);
FILE *fp;
if ((fp = fopen(filename, “r”)) == NULL)
{
printf(“error!”);
return -1;
}
int node_num = 0;
float x = 0;
fscanf(fp, "%d", &node_num); //Path node num is 5.
for (int i = 0; i <= node_num; i = i + 1)
{
fscanf(fp, "%f", &x); //path.node[0].vpos.x = 3.250000
}
fclose(fp);
float a = 1.2;
float b = 2.2;
sprintf(buff, "C:\\Users\\wangchaoran\\Desktop\\week7\\path_%d.txt", num);
FILE *path1 = fopen(buff, "w"); //打开文件
fprintf(path1, "%f %f\n", a, b);
fclose(path1);
}
return 0;
}