读,写数据
把数据写到文件中
//把数据写到文件中
FILE *file=fopen("文件名","wt");
if(file==NULL)
{
ShowInfoInSetUserSpace("不能保存用户坐标系!",ICON_ERROR);
}
fprintf(file,"%lf %lf %lf %lf\n%lf %lf %lf %lf\n%lf %lf %lf %lf\n%lf %lf %lf %lf",
RTH[0][0],RTH[0][1],RTH[0][2],RTH[0][3],
RTH[1][0],RTH[1][1],RTH[1][2],RTH[1][3],
RTH[2][0],RTH[2][1],RTH[2][2],RTH[2][3],
RTH[3][0],RTH[3][1],RTH[3][2],RTH[3][3]);
fclose(file);
//把数据写到文件中
FILE *file=fopen("文件名","wt");
if(file==NULL)
{
ShowInfoInSetUserSpace("不能保存用户坐标系!",ICON_ERROR);
}
fprintf(file,"%lf %lf %lf %lf\n%lf %lf %lf %lf\n%lf %lf %lf %lf\n%lf %lf %lf %lf",
RTH[0][0],RTH[0][1],RTH[0][2],RTH[0][3],
RTH[1][0],RTH[1][1],RTH[1][2],RTH[1][3],
RTH[2][0],RTH[2][1],RTH[2][2],RTH[2][3],
RTH[3][0],RTH[3][1],RTH[3][2],RTH[3][3]);
fclose(file);
从文件中读数据
FILE *fin=fopen(SetFileName[FILE_USER_SPACE],"rt");
if(fin==NULL)
{
ShowInfo("不能读取用户坐标空间参数,请先示教用户坐标系!",ICON_ERROR);
return;
}
fseek(fin, 0, SEEK_SET );
fscanf(fin,"%lf %lf %lf %lf\n%lf %lf %lf %lf\n%lf %lf %lf %lf\n%lf %lf %lf %lf",
&UserCoordRelToRobot[0][0],&UserCoordRelToRobot[0][1],&UserCoordRelToRobot[0][2],&UserCoordRelToRobot[0][3],
&UserCoordRelToRobot[1][0],&UserCoordRelToRobot[1][1],&UserCoordRelToRobot[1][2],&UserCoordRelToRobot[1][3],
&UserCoordRelToRobot[2][0],&UserCoordRelToRobot[2][1],&UserCoordRelToRobot[2][2],&UserCoordRelToRobot[2][3],
&UserCoordRelToRobot[3][0],&UserCoordRelToRobot[3][1],&UserCoordRelToRobot[3][2],&UserCoordRelToRobot[3][3]);
fclose(fin);
把数据写到文件中
#include "iostream.h"
#include "fstream.h"
void main()
{
fstream outfile;
outfile.open("1.txt",ios::out);
outfile<<2;
}
#include "iostream.h"
#include "fstream.h"
void main()
{
fstream outfile;
outfile.open("1.txt",ios::out);
outfile<<2;
}