我有一个 x,y,z 作为双精度类型的结构。我试图用空格分隔行,然后将该数组的值放入我的结构中,但它无法正常工作,有人可以告诉我该怎么做吗?
#include "_externals.h"
#include <vector>
typedef struct
{
double X, Y, Z;
} p;
p vert = { 0.0, 0.0, 0.0 };
int main()
{
char *path = "C:\\data.poi";
ifstream inf(path);
ifstream::pos_type size;
inf.seekg(0, inf.end);
size = inf.tellg();
double x, y, z;
char *data;
data = new char[size];
inf.seekg(inf.beg);
inf.read(data, size);
inf.seekg(inf.beg);
char** p = &data;
char *line = *p;
for (int i = 0; i < strlen(data); ++i)
{
const char *verts = strtok(line, " ");
//this isnt working
vert.X = verts[0];
vert.Y = verts[1];
vert.Z = verts[2];
++*line;
}
}
谢谢