I use ifstream to read a set of input from a file which consist of only numbers. I store these numbers in an char array. I need to use this numbers to do calculations. How can I convert dem to integer?
Yep, stringstreams are the way to go...
here's an example i found somewhere...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
#include <sstream>
int main()
{
usingnamespace std;
string s = "1234";
stringstream ss(s); // Could of course also have done ss("1234") directly.
int i;
ss >> i;
cout << i << endl;
return 0;
}