Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <wctype.h>
- using namespace std;
- string newstring;
- string currentstring;
- string firstname;
- string middlename;
- string lastname;
- string fullname;
- void test() {
- cout << endl << "This is a test" << endl;
- }
- void isstatus(char digit, char digit2) {
- enum begin { single = 'S', married = 'M', divorced = 'D' };
- if (digit2 == 'M') {
- currentstring = "Mr.";
- }else
- if(digit2 == 'F')
- switch (digit) {
- case single:
- currentstring = "Ms.";
- break;
- case married:
- currentstring = "Mrs.";
- break;
- case divorced:
- currentstring = "Ms.";
- break;
- default:
- cout << "Failed to Identify The IsStatus";
- cout << endl << digit << endl;
- break;
- }
- }
- void nameparser(string things, float position) {
- int i = position;
- int a;
- int b;
- string tempstring2;
- while (things[i] != '\0') {
- if (things[i] != ' ') {
- tempstring2 += things[i];
- }
- if (things[i] == ',') {
- lastname = tempstring2;
- b = lastname.length();
- lastname[b - 1] = ' ';
- tempstring2 = ' ';
- }
- if (things[i + 1] == '\0' || things[i - 1] == '.') {
- if (tempstring2 != " ") {
- firstname = tempstring2;
- }
- a = firstname.length();
- if (firstname[a - 1] == '.') {
- middlename = firstname[a - 2];
- middlename += firstname[a];
- firstname.erase(a - 2, a);
- }
- tempstring2 = ' ';
- }
- i++;
- }
- }
- int main()
- {
- ifstream fileInput;
- fileInput.open("C:\\temp\\New Text Document.txt");
- while (!fileInput.eof())
- {
- getline(fileInput, newstring);
- isstatus(newstring[2],newstring[0]);
- nameparser(newstring, 4);
- newstring.erase(0, 4);
- cout << "Original String: " << newstring << endl << "Standard String: ";
- cout << currentstring << " " << firstname << " " << middlename << " " << lastname << " " << endl << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment