正当な理由でsscanfを使用している可能性がありますが、少なくとも、ストリームを使用して情報を構造体にロードできることを指摘するのは良いことだと思います。
この場合、istringstreamクラスを使用することをお勧めします。これにより、値を文字列から値として読み取り、必要に応じてキャストできます。だから、あなたのコード、私はそれをこれに変えることができると思います:
std::string one = "v 100.32 12321.232 3232.6542";
struct Face {float x,y,z;};
std::vector<struct Face>obj;
char space[3];
// As mentioned previously, create a temporal Face variable to load the info
struct Face tmp; // The "struct" maybe can be omited, I prefer to place it.
// Create istringstream, giving it the "one" variable as buffer for read.
istringstream iss ( one );
// Replace this line...
//sscanf(one.c_str(), "%s %f %f %f",space,&obj[1].x1,&obj[1].y1,&obj[1].z1);
// With this:
iss >> space >> tmp.x >> tmp.y >> tmp.z;
// Add the temporal Face into the vector
obj.push_back ( tmp );
// As mentioned above, the first element in a vector is zero, not one
std::cout << obj[0].x1 << std::endl;
この場合、文字列からロードする値がある場合、istringstreamクラス(「sstream」を含める必要があります)が役立ちます。
私の答えが何らかの形であなたを助けることを願っています。