Click here to Skip to main content
15,901,283 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: SDI app executes CFrameWnd::OnCreate throwing Invalid Address specified to RtlValidateHeap Pin
Cedric Moonen12-Dec-09 22:18
Cedric Moonen12-Dec-09 22:18 
GeneralRe: SDI app executes CFrameWnd::OnCreate throwing Invalid Address specified to RtlValidateHeap Pin
sharion13-Dec-09 5:48
sharion13-Dec-09 5:48 
QuestionI can't get MAC by GetAdaptersAddresses [modified] Pin
DavidBrother12-Dec-09 4:57
DavidBrother12-Dec-09 4:57 
AnswerRe: I can't get MAC by GetAdaptersAddresses Pin
DavidBrother12-Dec-09 5:27
DavidBrother12-Dec-09 5:27 
GeneralRe: I can't get MAC by GetAdaptersAddresses Pin
Richard MacCutchan12-Dec-09 6:06
mveRichard MacCutchan12-Dec-09 6:06 
AnswerRe: I can't get MAC by GetAdaptersAddresses Pin
Richard MacCutchan12-Dec-09 6:11
mveRichard MacCutchan12-Dec-09 6:11 
GeneralRe: I can't get MAC by GetAdaptersAddresses Pin
DavidBrother12-Dec-09 16:34
DavidBrother12-Dec-09 16:34 
GeneralRe: I can't get MAC by GetAdaptersAddresses Pin
DavidBrother12-Dec-09 17:29
DavidBrother12-Dec-09 17:29 
QuestionTAPI send data Pin
cmos12-Dec-09 2:12
cmos12-Dec-09 2:12 
AnswerRe: TAPI send data Pin
Richard MacCutchan12-Dec-09 2:51
mveRichard MacCutchan12-Dec-09 2:51 
GeneralRe: TAPI send data Pin
cmos12-Dec-09 4:11
cmos12-Dec-09 4:11 
GeneralRe: TAPI send data Pin
Richard MacCutchan12-Dec-09 4:25
mveRichard MacCutchan12-Dec-09 4:25 
GeneralRe: TAPI send data Pin
cmos12-Dec-09 4:36
cmos12-Dec-09 4:36 
GeneralRe: TAPI send data Pin
Richard MacCutchan12-Dec-09 4:53
mveRichard MacCutchan12-Dec-09 4:53 
GeneralRe: TAPI send data Pin
cmos12-Dec-09 5:07
cmos12-Dec-09 5:07 
GeneralRe: TAPI send data Pin
Richard MacCutchan12-Dec-09 6:04
mveRichard MacCutchan12-Dec-09 6:04 
GeneralRe: TAPI send data Pin
cmos12-Dec-09 14:19
cmos12-Dec-09 14:19 
GeneralRe: TAPI send data Pin
Richard MacCutchan12-Dec-09 22:52
mveRichard MacCutchan12-Dec-09 22:52 
GeneralRe: TAPI send data Pin
cmos13-Dec-09 1:18
cmos13-Dec-09 1:18 
GeneralRe: TAPI send data Pin
Richard MacCutchan13-Dec-09 1:33
mveRichard MacCutchan13-Dec-09 1:33 
AnswerRe: TAPI send data Pin
armecos22-Feb-10 17:01
armecos22-Feb-10 17:01 
QuestionWriting in a file using CArchive class Pin
Le@rner11-Dec-09 22:47
Le@rner11-Dec-09 22:47 
AnswerRe: Writing in a file using CArchive class Pin
Nuri Ismail11-Dec-09 23:51
Nuri Ismail11-Dec-09 23:51 
Le@rner wrote:
but when i open the file the content inside it is

Apþÿÿ ?ñÔÈSû! @


This is absolutely normal because CArchive will write your data in binary mode. Smile | :)

If you want to write a text file you can use the CStdioFile[^] class like this:
CStdioFile file;
CFileException e;
if(!file.Open(_T("C:\\file.txt"), CFile::modeCreate | CFile::modeWrite | CFile::typeText, &e))
{
	TRACE(_T("File could not be opened %d\n"), e.m_cause);
}
else
{
        char c = 'A';
	int i = -400;
	float f = 1.25f;
	double d = 3.14159265;
	
        CString str;
	str.Format(_T("%c %d %f %f"), c, i, f, d);
	
        file.WriteString(str);
	file.Close();
}


Using the STL file streams could also be an option. In this case the code could be something like:
#include <fstream>

// Deal with both Unicode and Non-Unicode builds
#ifdef _UNICODE
	#define _tofstream std::wofstream
#else
	#define _tofstream std::ofstream
#endif

........

char c = 'A';
int i = -400;
float f = 1.25f;
double d = 3.14159265;
	
_tofstream fout;
fout.open(_T("C:\\file.txt"));
fout << c << _T(" ")<< i << _T(" ") << f << _T(" ")<< d;
fout.close();


I hope this helps! Smile | :)

Regards

Nuri Ismail
AnswerRe: Writing in a file using CArchive class Pin
pacotest17-Dec-09 18:42
pacotest17-Dec-09 18:42 
QuestionNamed Mutex not visible from DLL Pin
Bram van Kampen11-Dec-09 15:03
Bram van Kampen11-Dec-09 15:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.