1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <iomanip>
using namespace std;
int main ()
{
//put your code after this line
string s = "Tom Smith,1 Main Street,Rochester,New York,14623";
// printing original string
cout << "Original string <" << s << ">" << endl;
string szInput[5];
int locOfCma = s.find( ',' );
string name = s.substr(0,locOfCma);
string address = s.substr(locOfCma + 1,13);
string town = s.substr(locOfCma + 15, 30);
string zip = s.substr(locOfCma + 34, 5);
// use getline, ignore and replace.
do
{
//replaces comma after New York.
town.replace(18,1, " ");
// inserts space after Rochester,
town.insert(10, " ");
int atoi ( const char * zip);
cout << name << endl;
cout << address << endl;
cout << town << endl;
cout << zip << endl;
int strlen( const string * zip );
// Error checking for Zip
} while (strcmp (zip,szInput) != 0);
//put your code before this line
//keep output window open
return 0;
} //end main
|