C++ Sorting words?

Can someone give me a starting stone for this.

File looks like this

Zachary CAD Stephen
Billy BAD Manners

take those lines and arrange like this

NC= Zachary CAD Stephen
AccountDisp: Stephen CAD Zachary
DC= Zachary.Stephen

NC= Billy BAD Manners
AccountDisp: Manners BAD Billy
DC= Billy.Manners

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
// ADIT.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "windows.h"

#include <iostream>
#include <istream>
#include <fstream>
#include <string>

using namespace std;

string FileName;
string Contents;
string szAnswer;
string First, Last, Rank;

ifstream infile;


int _tmain(int argc, _TCHAR* argv[])
{
	SetConsoleTitle(L"Active Directory Import Tasker");

	bool Correct = false;

	do
	{
		cout << "Enter the file name:  ";
        getline(cin, FileName);
        infile.open (FileName, ifstream::in|ios::out);

		if (infile.good())
		{
			while ( !infile.eof() )
			{
				getline(infile, Contents); // Saves the line in STRING.
				cout << Contents << endl; // Prints our STRING.
			}

			cout << "\nIs this correct? ";
			getline(cin, szAnswer);

			if (szAnswer == "Y" || "y" )
			{
				cout << "\nReading file......\n" ;
				Sleep(2000);
				Correct = true;
			}
		}
		else
			cout << "File not found!!\n";
	}
	while(!Correct);
	
		system("Pause");
	return 0;
}


Can someone give me a starting stone for this.

File looks like this

Zachary CAD Stephen
Billy BAD Manners

take those lines and arrange like this

NC= Zachary CAD Stephen
AccountDisp: Stephen CAD Zachary
DC= Zachary CAD Stephen

NC= Billy BAD Manners
AccountDisp: Manners BAD Billy
DC= Billy BAD Manners
Last edited on
Can you please provide the output that is generated?
Enter the file name: C:\c.txt
Zachary Schu
Derick Peter

Is this correct? Y
Reading file...........
Press any key to continue..........
system("Pause");

That is what prints "Press any key to continue..........". What happens after you press a key?
Zaita, Thanks, I feel entirely to stupid right now. It prints Test. Its been a long day for me.
no probs :)
Want to give me one last hand?
Just ask :) always someone around, though it's getting late for me :)
Topic archived. No new replies allowed.