| | |
Saving to a file
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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
Thanx,
Atrus
•
•
Join Date: Aug 2005
Posts: 80
Reputation:
Solved Threads: 2
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
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
![]() |
Similar Threads
- how can i implement a string from Jtextfield and saving it to a file (Java)
- Quark upgrade lost file (was: please... im begging here, someone help!!) (Mac Software)
- Saving a file (Java)
- Saving a file using C++ (C++)
Other Threads in the C Forum
- Previous Thread: Permutation of any word short and fast without pointers
- Next Thread: How to perform pow(x,y) where x and y are floats??
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide inches infiniteloop initialization interest kilometer km lazy linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape single socketprograming socketprogramming spoonfeeding stack standard strchr string strings structures suggestions system systemcall test testautomation unix user voidmain() wab win32api windows.h





