Return to Snippet

Revision: 31354
at September 3, 2010 05:14 by oznek


Initial Code
#include <sstream>
#include <iostream>

using namespace std;

int main()
{
    string s = "-123";
    
    int i;
    bool success;
    istringstream myStream(s);

    if (myStream>>i)
        success = true;
    else
        success = false;
    
    std::cout << success << std::endl;
    std::cout << i << std::endl;
}

Initial URL
http://www.techbytes.ca/techbyte99.html

Initial Description

                                

Initial Title
Converting string to int

Initial Tags
c

Initial Language
C++