여기에 무슨 일이 일어나고 있는지 모르겠습니다. 두 개의 문자열을 두 개로 변환하고 첫 번째 문자열은 항상 통과하지만 두 번째 문자열은 변환되지 않으며 어떤 방식 으로든 전환 할 수 있습니다. 여기에 코드입니다 :변환 문자열을 두 번 사용 하시겠습니까?
#include <iostream>
#include <math.h>
#include <string>
#include <sstream>
using namespace std;
int main() {
string temp;
double ax,bx,cx,ay,by,cy;
cout << "Enter x and y for point 1 (separated by a comma)";
cin >> temp;
int where=temp.find(",");
int hmm=temp.length()-where;
cout << hmm << endl << where << endl;
cin.get();
stringstream ss;
string stAx,stAy;
stAx= (temp.substr(0,where));stAy = (temp.substr(where+1, hmm-1));
ss << stAx;ss >> ax;
ss << stAy;ss >> ay;
cout << "Ax: " << ax << endl;
cout << "Ay: " << ay << endl;
system("pause");
return 0;
}
사람이 내가 잘못 알아낼 수 있습니까?
미리 감사드립니다.
이 코드의 일부가 누락 된 것 같다, 그래서 나는이 당신의 문제가 무엇인지 짐작할 수 있습니다. 하지만 boost :: lexical_cast()를 보셨나요? – Axel