Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

kafkar

simple file i/o question

This topic is 5129 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, this is probably a real easy question but.... From my experience with c++ \n has always worked as a crlf in file i/o... However, I am making a windows app and am using writefile, and I have tried concating "\n" onto my buffer, as well as outputting it to file separatly. The result is all of my stuff appearing on the first line :\ Is there a special way to do it while using writefile? Or am I just screwing up something really basic? Thanks. Mada Mada Dane

Share this post


Link to post
Share on other sites
Advertisement


for (int i = 0; i < itemsinlist; i++)
{
strcpy(szBuffer, szListLinks);
strcat(szBuffer, "\n");
WriteFile(hFile, szBuffer,strlen(szBuffer) * sizeof(char),
&dwBytesWritten, NULL);
}

Also tried

for (int i = 0; i < itemsinlist; i++)
{
strcpy(szBuffer, szListLinks[i]);
WriteFile(hFile, szBuffer,strlen(szBuffer) * sizeof(char),
&dwBytesWritten, NULL);
WriteFile(hFile, "\n",sizeof(char),&dwBytesWritten, NULL);
}



Both have 1 long line of text in file. :
________________

Mada Mada Dane


[edited by - kafkar on May 9, 2004 9:15:55 PM]

[edited by - kafkar on May 9, 2004 9:16:56 PM]


[edited by - kafkar on May 9, 2004 9:17:29 PM]

Share this post


Link to post
Share on other sites
What are you using to open the file? ofstream, FILE pointer? About the only suggestion I can make - check that you are not outputting in binary format?

Share this post


Link to post
Share on other sites
not ofstream.

Using createfile() api call Windows C, not c++.

EDIT: Well I just opened up the file in Wordpad instead of TextPad and it has a break in that one... Though it usually shows correctly in textpad from my past experience... wtf?!...


[edited by - kafkar on May 9, 2004 9:21:48 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by kafkar
From my experience with c++ \n has always worked as a crlf in file i/o...
Nope. ''\n'' is newline or linefeed; ''\r'' is carriage return. You''ll need both ("\r\n") for Win32 APIs.

It''s in the docs. Read them.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!