hello all, new semester, new problems...ahhh I love it!
anyhow, I'm supposed to write a simple command line argument parser, and for some odd reason it does not want to work. The requirments are the following:
if the command line is:
then the prog should displayCode:parse 123ds24
if the command line isCode:123 24
thenCode:parse 123ddd36 356m7
I think you know what I mean...anyhow, below is my code...the problem arises when there is a letter in the string, it just skipps it and goes to the next argument, any suggestions?Code:123 36 356 7
thanks,Code:#include <iostream> #include <cctype> using namespace std; int main(int argc, char *argv[]) { int intVal = 0; char c; if ( argc == 1 ) { cout << "\nThere is nothing to parse!\n"; cout << endl; } else { for ( int i = 1; i < argc; i++ ) { c = argv[i][i-1]; if ( isalpha(c) ) continue; else{ intVal = atoi( argv[i] ); cout << intVal << endl; } } } return 0; }
axon