C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 19th, 2005, 10:36 AM
clever_idiot clever_idiot is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 4 clever_idiot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 10 sec
Reputation Power: 0
Ofstream.write problems

hello,
I need to write to a txt file, line by line.

i have:
PHP Code:
 dnffile.write(strMsgOutstrMsgOut.GetLength()); 

this will write the line, but not put a newline char at the end, so subsequently, when the code runs again, the next line appears on the same as the one before.

any ideas?

Reply With Quote
  #2  
Old May 19th, 2005, 05:19 PM
ubergeek ubergeek is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 ubergeek User rank is Private First Class (20 - 50 Reputation Level)ubergeek User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 40 m 27 sec
Reputation Power: 4
Send a message via AIM to ubergeek
Code:
 dnffile.write(strMsgOut, strMsgOut.GetLength()); //does this work? what is this GetLength function?
 dnffile << endl; //add newline and flush the output buffer
 

Reply With Quote
  #3  
Old May 21st, 2005, 12:37 PM
clever_idiot clever_idiot is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 4 clever_idiot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 10 sec
Reputation Power: 0
GetLength() returns an int value of the length of the string, its a member of CString.

the << doesnt work in VC++, i get errors claiming that there is no appropriate conversion.

Reply With Quote
  #4  
Old May 21st, 2005, 06:26 PM
ubergeek ubergeek is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 ubergeek User rank is Private First Class (20 - 50 Reputation Level)ubergeek User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 40 m 27 sec
Reputation Power: 4
Send a message via AIM to ubergeek
all right, here's another method:
I don't know how CStrings work (not using VC++ myself), but add a newline character on to the end. (probably something like strMsgOut += '\n'). \n is the newline character. Alternatively, if you can't modify strMsgOut, then put
Code:
dnffile.write('\n', 1);

Reply With Quote
  #5  
Old May 21st, 2005, 06:42 PM
clever_idiot clever_idiot is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 4 clever_idiot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 10 sec
Reputation Power: 0
Quote:
Originally Posted by ubergeek
all right, here's another method:
I don't know how CStrings work (not using VC++ myself), but add a newline character on to the end. (probably something like strMsgOut += '\n'). \n is the newline character. Alternatively, if you can't modify strMsgOut, then put
Code:
dnffile.write('\n', 1);


thanks that worked

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Ofstream.write problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT