istream question

Is there a way that I can check to see if the user input an 'x'? I don't want my slope intercept form to look like y = m+b. I want it to be this.. 1x+8 (i don't care about the y=).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
istream &operator>>(istream &in, Slope &num1)
{
	char x;
	double m, b;

	in >> m; // slope
	in >> x; // To read the 'x' from the istream
	in >> b; // y-intercept
	
	num1.setm(m);
	num1.setb(b);

	return in;
}
Your best bet is to read a string from the keyboard and then parse it.

This sounds like a pretty simple task for boost.regex.

http://www.boost.org/doc/libs/1_46_1/libs/regex/doc/html/index.html
Topic archived. No new replies allowed.