File write issues

I am making a program for a password-protected journal with the option to leave it locked or unlocked. (they can leave it non-password protected as an option)
I'm getting a pop-up that says;

"The line endings in the following file are not consistent. Do you want to normalize the line endings?
file name
yes / no"

Anyone know what this means? it doesn't seem to do anything if I click yes or no.

Sorry, the code's kind of long, I'm doing this as a way of getting experience with different options while writing to a file.
I think the main issue is in my newlog() function starting on line 171.
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>

using namespace std;
void findDay(); // find a specific date and start printing to screen. #####
string onOpen(); //check if diary is locked, ask for password if it is //if newfile then ask for a password to be made #####
string changePW(); //Ask for current password before changing it.
void newLog(); //start writing for a new day ####
void addLog(); //add writing to the end of the entry for a specific date
void viewAll(); //print to screen all entries from the beginning #####


int main()
{
	string input = "0", output = "0", option, end="a", pass;
	end=onOpen();
	if(end !="Passthrough" && end!= "pass req")
	{
	cout<<"What is the password?"<<endl;
	cin>>option;
	}
	else if(end=="pass req")
	{
		ofstream newF("file.jnl");
		cout<<"Enter a password for your new journal"<<endl;
		cin>>pass;
		if(newF.is_open())
		{
newF<<"unlocked"<<endl<<pass<<endl;
newF.close();
		}

	}
	if(option==end||end=="Passthrough")
	{
	while(end!="unlocked" && end!="lock")
	{
		cout<<"     ****************   My __ Journal   *****************\n \n"<<endl;
	cout<<"Options:\n(1) Find a log by title-name. \n(2) Veiw entire Diary \n(3) Enter a new Log (type the word 'stop' to end the entry)\n(4)Add to a log" <<endl;
	cin>>option;
	if(option == "1")
	{
	findDay();
	}
	else if(option == "2")
	{
		viewAll();
	}
	else if(option =="3")
	{
		newLog();
	}
	else if(option == "4")
	{
		addLog();
	}
	cout<<endl<<endl<<"Type 'unlocked' to leave your diary unlocked.\nType the word 'lock' to password-protect it. \nType anything else to go to the main menu."<<endl<<endl;
		cin>>end;
		
	}
	if(end=="lock")
	{
		ofstream lock("file.jnl", ios::binary | ios::in | ios::out);

lock.seekp(0,ios::beg);
lock.write("..lock..", 8);


	}
	else if(end=="unlocked")
	{
		ofstream lock("file.jnl", ios::binary | ios::in | ios::out);

lock.seekp(0,ios::beg);
lock.write("unlocked", 8);
	}
	}
	return 0;
}
string onOpen()
{
	string lock, password;
	fstream open("file.jnl", ios::in | ios::out);
	if(open.is_open() && open.good())
	{
		open>>lock>>password;
		if(lock=="..lock..")
		{
			return password;
		}
		else
		{
			return "Passthrough";
		}
	}
	else
	{
		open<<"unlocked"<<endl<<"password";
		return "pass req";
	}

}
void findDay()
{
	cin.ignore();
	string input = "0", output="0", date;
			cout<<"Enter the title you'd like to search for"<<endl;
		getline(cin,date);
		cout<<endl<<endl<<endl;
		ifstream fileIn("file.jnl", ios::binary);
	if(fileIn.is_open())
	{
		
	while(fileIn.good() && input != date+":")
	{
		getline(fileIn, input);
	}
	cout<<input<<endl;
		while(fileIn.good() && input != "stop ")
	{
		getline(fileIn, input);
		cout << input<<endl;
	}
	fileIn.close();
	}
	else
	{
		cout<<"Couldn't open file";
	}
}
void addLog()
{

		cin.ignore();
	string input = "0", output="0", date;
	int pos;
			cout<<"Enter the title you'd like to search for"<<endl;
		getline(cin,date);
		cout<<endl<<endl<<endl;
		fstream fileAdd("file.jnl", ios::binary | ios::in |ios::out);
	if(fileAdd.is_open())
	{
		
	while(fileAdd.good() && input != date+":")
	{
		getline(fileAdd, input);
	}
	cout<<input<<endl;
		while(fileAdd.good() && input != "stop ")
	{
		getline(fileAdd, input);
		cout << input<<endl;
	}
		pos=fileAdd.tellp();
		fileAdd.seekp(pos-5);
		while(fileAdd.good() && output!= "stop")
		{
			getline(cin, output);
				fileAdd<<output<<endl;
		}

	fileAdd.close();
	}
	else
	{
		cout<<"Couldn't open file";
	}
}
void newLog() //start writing for a new day
{
		string input = "0", output = "0", title="0";
		cin.ignore();
		cout<<"Enter the Title of the current log"<<endl;
		getline(cin, title);
		title+=":";
		cout<<title<<endl;
		
		cout<<"_____________________________________"<<endl;
	ofstream fileout("file.jnl", ios::binary | ios::app);
	if(fileout.is_open())
	{
		fileout<<endl<<title<<endl;
		fileout<<endl;
		while(output != "stop")
		{
			getline(cin, output);
			fileout<<output<<" "<<endl;
		}
		fileout<<endl<<"-----------------------------------------------"<<endl;
		fileout.close();
	}

}
void viewAll()
{
		string input = "0", output="0";
		ifstream fileIn("file.jnl", ios::binary);
	if(fileIn.is_open())
	{
		while(fileIn.good())
	{
		getline(fileIn, input);
		cout << input<<endl;
	}
	fileIn.close();
	}
	else
	{
		cout<<"Couldn't open file";
	}
}


Any guesses what's going wrong or what I need to change?
Last edited on
I'm getting a pop-up that says;
Who does it say?
Do you use Visual Studio or similar on windows?
I this message pops up when you have saved a file in UNIX, windows needs CRLF at the end.

I dont think saying yes or now would matter, but if you want to get rid of the annoying message then then you need to say yes
Who's on second. What's stealing home?

Uh. Sorry, dumb joke. I put what the pop-up says in the quote box at the top there.
Last edited on
Topic archived. No new replies allowed.