I don't know what's going on here. I am converting two strings to doubles and the first one always goes through, but the second doesn't and it doesn't matter which way I switch them! Here's the code:
#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;
}
Can anybody figure out what I'm doing wrong?
Thanks in advance!