Saving to a file

Reply

Join Date: Mar 2005
Posts: 64
Reputation: atrusmre is an unknown quantity at this point 
Solved Threads: 0
atrusmre's Avatar
atrusmre atrusmre is offline Offline
Junior Poster in Training

Saving to a file

 
0
  #1
Nov 18th, 2005
What is the best way to save to a file using a MFC Dialog based program? I need it to output mutipule data type (CString, int) to a file. I also need it to read the data from the file to update the controls (i.e. an options dialog). I've tried using ifstream, and ostream, but to no avail. I can output the int fine, but the CString is another story. If the CString is a control ( or was a control) then the output looks weird (I get 7 numbers followed by one letter, I think it's OCT?). And I can't get it to read properly from the file. How do I do this? Should I be using something else to save?

Thanx,
Atrus
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 80
Reputation: Daishi is an unknown quantity at this point 
Solved Threads: 2
Daishi Daishi is offline Offline
Junior Poster in Training

Re: Saving to a file

 
0
  #2
Nov 18th, 2005
You can check out CFile, if you want to stick with the MFC stuff and not mess with STL or the C file input/output functions. For CFile:

http://msdn.microsoft.com/library/de..._MFC_CFile.asp

As for how to write a string to a file using STL, you should be using the GetBuffer() and GetLength() methods of CString and then writing to the file as a character array, you shouldn't be using the << and >> operators, those do something slightly different for CString objects than they do for regular stl string objects.

-Fredric
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC