Getting an error while using 'isdigit();'

Hello, im getting an 'exception: std::out_of_range at memory location 0x00AFF71C.' error when program gets to the 'isdigit' function. I dont really see why, sending a char to evaluate, expecting a true or false in return. heres my code. (Just included relevant code. Ill be checking for answers regualrly, if any more code is nedded ill post it in the comments.)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
      string expresion, posfija;
	char x;
	Pila<char> s;

	header();//just a line of text
	cout << "\t Expresion to convert." << endl;
	cin >> expresion;
	cin.ignore();
	system("cls");
			do
			{
				x = expresion.front();
				expresion.erase(expresion.front());

				if (isdigit(x))
	         		{
					posfija.push_back(x);
				}
   //the do-while continues for a while, but i get the error right at the is digit function. 
http://www.cplusplus.com/reference/string/string/erase/
you are calling this version string& erase (size_t pos = 0, size_t len = npos);
pos
Position of the first character to be erased.
If this is greater than the string length, it throws out_of_range.
Note: The first character in str is denoted by a value of 0 (not 1).
Topic archived. No new replies allowed.