I'm trying to get my program to go through the string typed in by the user and strip it of EVERYTHING but the numbers. I can't place my finger on what I'm missing. Help please?
Code:#include<iostream> #include<string> using namespace std ; int main() { string myString ; cout << "Please enter string/numbers: " ; getline( cin, myString ) ; // disgard anything that's not an int for ( int x = 0 ; x < 10 ; x++ ) if ( !isdigit( myString[ x ] ) ) myString.erase( x, 1 ) ; // display contents cout << myString << endl ; } // end main



LinkBack URL
About LinkBacks


