Discussion:
I can't produce a carriage return???
(too old to reply)
Guskz Kz
2015-06-21 14:32:08 UTC
Permalink
Instead of 0 carriage return 0, I get 00 in the text file below, what is wrong???




*************************
CString pBuffer;
DWORD ptext = 0;

ClientFile.Format(_T("Textfile.txt"));


if (!p_file.GetStatus(ClientFile, status))
!p_file.Open(ClientFile, CFile::modeCreate | CFile::modeReadWrite);


else if (!p_file.Open(ClientFile, CFile::modeReadWrite))
MessageBox(NULL, (LPCWSTR) "Can't open file", (LPCWSTR) "file", MB_OK);




pbuffer.Format(_T("%1u\r\n"), ptext);



p_file.SeekToEnd();
p_file.Write(pbuffer, pbuffer.GetLength());

p_file.SeekToEnd();
p_file.Write(pbuffer, pbuffer.GetLength());


p_file.Close();
Guskz Kz
2015-06-21 15:07:09 UTC
Permalink
Post by Guskz Kz
Instead of 0 carriage return 0, I get 00 in the text file below, what is wrong???
*************************
CString pBuffer;
DWORD ptext = 0;
ClientFile.Format(_T("Textfile.txt"));
if (!p_file.GetStatus(ClientFile, status))
!p_file.Open(ClientFile, CFile::modeCreate | CFile::modeReadWrite);
else if (!p_file.Open(ClientFile, CFile::modeReadWrite))
MessageBox(NULL, (LPCWSTR) "Can't open file", (LPCWSTR) "file", MB_OK);
pbuffer.Format(_T("%1u\r\n"), ptext);
p_file.SeekToEnd();
p_file.Write(pbuffer, pbuffer.GetLength());
p_file.SeekToEnd();
p_file.Write(pbuffer, pbuffer.GetLength());
p_file.Close();
I even added below after p_file.Write:

p_file.Flush();
Guskz Kz
2015-06-21 19:31:44 UTC
Permalink
Post by Guskz Kz
Instead of 0 carriage return 0, I get 00 in the text file below, what is wrong???
*************************
CString pBuffer;
DWORD ptext = 0;
ClientFile.Format(_T("Textfile.txt"));
if (!p_file.GetStatus(ClientFile, status))
!p_file.Open(ClientFile, CFile::modeCreate | CFile::modeReadWrite);
else if (!p_file.Open(ClientFile, CFile::modeReadWrite))
MessageBox(NULL, (LPCWSTR) "Can't open file", (LPCWSTR) "file", MB_OK);
pbuffer.Format(_T("%1u\r\n"), ptext);
p_file.SeekToEnd();
p_file.Write(pbuffer, pbuffer.GetLength());
p_file.SeekToEnd();
p_file.Write(pbuffer, pbuffer.GetLength());
p_file.Close();
I got the answer from another website which said to turn off unicode, so now it works.

Thanks.

Continue reading on narkive:
Loading...