#include #include #include using namespace std; int main() { //Example for comparing ascii strings. string a = "Commander", b = "Lieutenant"; if( a < b ) cout << a << endl; else cout << b << endl; //Ascii values cout << endl << "65: " << char(65) << endl; cout << "97: " << char(97) << endl << endl; //Example for converting string to integer and comparing. int a_int, b_int; a = "456", b = "123"; a_int = atoi(a.c_str()); b_int = atoi(b.c_str()); cout << a_int << " " << a_int+1 << endl; if( a_int < b_int ) cout << a << endl; else cout << b << endl; cout << endl; //Example for reading one token at a time in a string. string inputLine = "BowlingFrames 8 N/A 16 33 56 61 69 73 81 90 100"; string nextToken; int nextTokenInt; int nextSpace = inputLine.find(" "); int length = inputLine.length(); nextToken = inputLine.substr(0,nextSpace); inputLine = inputLine.substr(nextSpace+1, length-nextSpace); cout << "nextToken: " << nextToken << endl << endl; //Repeat once for each token. nextSpace = inputLine.find(" "); length = inputLine.length(); nextToken = inputLine.substr(0,nextSpace); inputLine = inputLine.substr(nextSpace+1, length-nextSpace); cout << "nextToken string: " << nextToken << endl; if (nextToken != "N/A") { //Process the new integer nextTokenInt = atoi( nextToken.c_str() ); cout << "nextToken int: " << nextTokenInt << endl; cout << "add 1: " << nextTokenInt+1 << endl; //if( nextTokenInt < minimum) //{ // set as the minimum //} } cout << endl; //A for loop can repeat a process i times. for( int i=0; i<11; i++) { //Some process. } return 0; }