Using C-String vs String Class

Hey guys, I'm working on a homework assignment where I have to write simple program to re-arrange someone's name. The catch is that I need to write two versions of it: one using C-String method and one using the String class method. I already finished the String class one, and now I'm having trouble trying to convert/translate it into String class. Any help?

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
#include <iostream>
#include <string>

using namespace std;

int main()
{
     string goAgain;
     
     do
     {
          string first, middle, last, fullName;
          char ch;			

          system("CLS");
          cout<< "Enter your full name: ";
          cin>> first >> middle;
  
          if (cin.peek()  != '\n')
          {
	           cin>> last;
	           fullName = last + ", " + first + " " + middle.at(0) + ". ";
	           cout << "Your name is: ";
	           cout << fullName << endl;
          }

          else
          {
               fullName = middle + ", " + first;
	           cout << "Your name is: ";
	           cout << fullName << endl << endl;
          }
          
          cout<<"Want to try with another name?\n";
          cout<<"(Enter yes or no): ";
          cin>>goAgain;
          
     }while (goAgain == "Yes" || goAgain == "yes");
     
     
     system("PAUSE");
	 return EXIT_SUCCESS;
}
Topic archived. No new replies allowed.