Output and Append

I am trying to output information to the end of a file with | as a delimiter. However when I run it, nothing is added to that text document. Could it just be that using pathName is not actually opening the file? Or am I missing something simple?

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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
 int main()
{

	
	char confirm;
	char reply;

	int count = 0;
	

	string pathName;
	string name;
	string album;
	string songTitle;
	string songArtist;
	string songDuration;
	string songAlbum;
	ofstream outputFile;

	


	cout << "Welcome to Edward's Song Database. " << endl;

	// Loads file
	count = loadFile(pathName);

	do
	{
		// Output

		cout << "Enter Q to (Q)uit, Search (A)rtist, Search (T)itle of Album, (S)how all. " << endl;
		cout << "You can also (E)nter a new song or (R)emove a song. " << endl;
		cin >> reply;

		// Selection
		switch (reply)
		{
		case'a':
		case'A':

			cin.ignore();
			cout << "Artist's Name: ";
			getline(cin, name);
			showSongsByArtist(count, name);
			cout << " " << endl;

			break;

		case'e':
		case'E':

			cout << "What is the title of the song? " << endl;
			cin >> songTitle;
			cout << "Who is the artist?" << endl;
			cin >> songArtist;
			cout << "How long is the song? " << endl;
			cin >> songDuration;
			cout << "What is the name of the album? " << endl;
			cin >> songAlbum;

			cout << songTitle << " by " << songArtist << " on album " << songAlbum << ". Duration of song is " << songDuration << ". " << endl;

			do
			{

				
				cout << "Is this correct? " << endl;
				cin >> confirm;

				switch (confirm)
				{
				case'y':
				case'Y':
					break;

				case'n':
				case'N':
					
					cout << "What is the title of the song? " << endl;
					cin >> songTitle;
					cout << "Who is the artist?" << endl;
					cin >> songArtist;
					cout << "How long is the song? " << endl;
					cin >> songDuration;
					cout << "What is the name of the album? " << endl;
					cin >> songAlbum;

					cout << songTitle << " by " << songArtist << " on album " << songAlbum << ". Duration of song is " << songDuration << ". " << endl;
					
					break;

				default:
					cout << "Invalid input. Please try again. " << endl;
					break;

				}

			} while (confirm != 'y' && confirm != 'Y');

			outputFile.open(pathName, ios::app);

			outputFile << "|" << songTitle << "|" << songArtist << "|" << songDuration << "|" << songAlbum;

			outputFile.close();

			break;
Well I think I figured out the issue. For the outputFile, it needs to have double \\ (i.e. C:\\songs.txt) while the pathName at the beginning only has one \ (i.e. C:\songs.txt). So I guess the next question is, is there an easy way to add that extra \ into pathName somehow or should the user have to re-input the path with those added manually?
Topic archived. No new replies allowed.