12345678
#include <string> #include <cstdlib> ... int x[5]; string s; ... x[i] = atoi(s.c_str()); ...
1234567
std::stringstream stream; std::string str="12"; stream <<str; int n; if (!(stream >>n)){ //could not convert }
f3.cpp:5: error: aggregate ‘std::stringstream stream’ has incomplete type and cannot be defined
123456789101112
#include <iostream> #include <string> using namespace std; int main(){ std::stringstream stream; std::string str="12"; stream <<str; int n; if (!(stream >>n)){ //could not convert } }
#include <sstream>
123
#include <boost/lexical_cast.hpp> int n = boost::lexical_cast<int>( str );