Monday, May 28, 2012

How to convert string to integer in C++

With the help of stringstream a string can be converted into integer
 

int str2int (const string &str) {
stringstream ss(str);
int n;
ss >> n;
return n;
}


No comments:

Post a Comment