problem with atoi

hello everyone,
I've been trying to solve this problem but there was no use.It gives this error: "'atoi' : cannot convert parameter 1 from 'std::string' to 'const char *'".Am I doing something wrong?
int main()
{
	int x,y;
	string input,input1;
	cout<<"Please enter the coordinates "<<endl;
	cin >> input;
	if((input.at(0) == '(') && (input.at(input.length()-1) == ')'))
	{
		int pos= input.find(',');
		int pos_reverse= input.rfind(',');
		if (( pos != string::npos) && (pos_reverse == pos))
		{
			string xstr,ystr;
			xstr = input.substr(1, pos-1);
		    ystr = input.substr(pos+1, input.length()-pos-2);
			if( inputcheck(xstr) && inputcheck(ystr))
			{
				
			x = atoi(xstr);
			y = atoi(ystr);
			}
		}
			
	}
This is just the main function by the way.
atoi takes a const char*, not an std::string. Use the c_str() method.
Are there any other way doing it besides c_str? I think we haven't learned that in class. thank you
Yes. Use an std::stringstream like so:

std::stringstream(xstr)>>x;
Topic archived. No new replies allowed.