The strange this is that I am just writing out char(10), not =
char(13) too. That section of code is as follows:
struct Calendar_Entry {
int id;
string start_date, end_date;
string title;
string description;
};
=20
vector<Calendar_Entry> entry_list(0);=20
. . .
const char End_of_Entry =3D char(10);
const char End_of_Field =3D char(124);
=20
Calendar_Entry entry;
. . .
for (int i=3D0; i < entry_list.size(); i++)
{
MK_cal_file << entry_list[i].id << End_of_Field;
MK_cal_file << entry_list[i].start_date << End_of_Field;=20
MK_cal_file << entry_list[i].end_date << End_of_Field;
MK_cal_file << entry_list[i].description << End_of_Entry;
}
I write out a string just before it, but that shouldn`t matter. =
Alan
From: jos...@ya...
Subject: Re: [Dev-C++] character 10
--- Alan Thomas escribi=F3: > I`m having a=20
strange problem. I am writing a program that
> decodes a file (holds calendar data) and encodes entries for
> appending to the file. At the end of each entry when I view the file
> in Notepad, there is a solid block. When I wrote a program to use
> get() to determine the character, it turned out to be integer value
> of 10. So, when I wrote the encoding code, at the end of each entry
> I wrote char(10) to the file.
> The items I appended to the file all have what appears to be
> a carriage return at the end of each entry. However, when I read the
> end of entry character with get(), it says it is an integer value 10!
> So, why would it look differently in the file (solid block vs. CR)?
>=20
> =20
> =
Thanks, Alan
Alan,
=20
char(10) is '\n', the line feed character. When you paste into
Notepad you get the solid block in Microsoft's edit boxes
(Notepad is a simple edit box) unless you add also the char(13),
ie '\r' the carriage return.
Hope this help.
Cheers,
Chemanuel
|