Organizing my output

I am having some issues organizing my output and would appreciate some tips on how to fix it.

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

using namespace std;

void changes(string &);
void changes2(string &);
void table(void);



int main()

{
    ifstream fin("names.txt");
    string names;   // First Name : Last Name
    string names2; // Last Name : First Name
    
    
    
         table();
         while (getline(fin,names)){
              changes(names); 
              
              cout << names << endl;
              changes2(names);
          }
       
    
 system("PAUSE");
 return 0;
}
void table(void) // Table Heading
{
     cout << "First "    " Last  " << "         Last "    " First" << 
     "      " << "  First--Last" << endl;
     return;
     }
void changes(string &names) // Breaks up names from First/Last into Last/First

{
      string lastname,firstname;
      
      firstname = names.substr(0,5);
      lastname = names.substr(5,11);
      cout << endl << "                  " << lastname << " " << firstname << endl;
      return;
      }
void changes2(string &names) // Adds -- between names
{
     
     
     names.insert(5,"--");
     cout << "                                          " << names << endl;
     
     return;
     }
      
       
       

First  Last           Last  First        First--Last

                   Adams Billy
Billy Adams
                                          Billy-- Adams

                   Washington Benny
Benny Washington
                                          Benny-- Washington

                   Carter Donna
Donna Carter
                                          Donna-- Carter

                   Smith Eddie
Eddie Smith
                                          Eddie-- Smith

                   Johnson Ronny
Ronny Johnson
                                          Ronny-- Johnson
Press any key to continue . . .

I wanted the names to be more stacked and in neater rows. Every time I shuffled something around, my code would break. Any tips welcome. Thanks.
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
68
69
#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>

using namespace std;

void changes(string &);
void changes2(string &);
void table(void);



int main()

{
	ifstream fin("names.txt");
	string names;   // First Name : Last Name
	string names2; // Last Name : First Name



	table();
	while (getline(fin, names)){
		changes(names);

		cout << setw(20) << left << names;
		changes2(names);
	}


	system("PAUSE");
	return 0;
}
void table(void) // Table Heading
{
	cout << setw(20) << left <<  "First  Last" << 
		    setw(20) << left << "Last  First" << 
		    setw(20) << left <<"First--Last" << endl;
	return;
}
void changes(string &names) // Breaks up names from First/Last into Last/First

{
	string lastname, firstname;
	string temp;
	int spaceIndex;
	spaceIndex = names.find(' ');
	firstname = names.substr(0, spaceIndex);
	lastname = names.substr(spaceIndex + 1, 11);
	temp += lastname;
	temp += " ";
	temp += firstname;
	cout << endl << setw(20) << left << temp;
	return;
}
void changes2(string &names) // Adds -- between names
{
	string temp;
	int spaceIndex;
	spaceIndex = names.find(' ');
	temp = names.substr(0, spaceIndex);
	temp += "--";
	temp += names.substr(spaceIndex + 1);
	cout << setw(20) << left << temp << endl;

	return;
}
Topic archived. No new replies allowed.