Click here to Skip to main content
15,886,067 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Another question about binary files... Pin
John R. Shaw12-Feb-06 7:20
John R. Shaw12-Feb-06 7:20 
GeneralRe: Another question about binary files... Pin
Lord Kixdemp12-Feb-06 7:28
Lord Kixdemp12-Feb-06 7:28 
QuestionCArray - How to implement Multidimensional arrays? Pin
RockyJames11-Feb-06 8:04
RockyJames11-Feb-06 8:04 
AnswerRe: CArray - How to implement Multidimensional arrays? Pin
Kevin McFarlane11-Feb-06 8:39
Kevin McFarlane11-Feb-06 8:39 
GeneralRe: CArray - How to implement Multidimensional arrays? Pin
RockyJames11-Feb-06 8:50
RockyJames11-Feb-06 8:50 
AnswerRe: CArray - How to implement Multidimensional arrays? Pin
Gary R. Wheeler12-Feb-06 4:49
Gary R. Wheeler12-Feb-06 4:49 
QuestionHow to get a VC++.Net (2003) AddIn working? Pin
Axter11-Feb-06 6:51
professionalAxter11-Feb-06 6:51 
QuestionWriting std::string to a binary file? Pin
Lord Kixdemp11-Feb-06 6:43
Lord Kixdemp11-Feb-06 6:43 
Hello everyone! Big Grin | :-D
I'm doing a program to learn how to use binary files... Poke tongue | ;-P

I have a struct that has one member of type std::string and one int. I want to write that struct to a binary file, but just the int gets written!

// Open output file<br />
fstream dat_file(file.c_str(), ios::out | ios::binary);<br />
<br />
// Person object<br />
	Person person;<br />
<br />
	// Add info to object<br />
	person.FullName = fullName;  // fullName is also a string<br />
	person.Age = atoi(strAge.c_str());<br />
<br />
	// Write object to file<br />
	dat_file.write((char*) &person, sizeof(Person));<br />
<br />
	dat_file.close();


Why won't it write the name to the file? Thanks! Wink | ;-)

Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
AnswerRe: Writing std::string to a binary file? Pin
Ravi Bhavnani11-Feb-06 6:59
professionalRavi Bhavnani11-Feb-06 6:59 
GeneralRe: Writing std::string to a binary file? Pin
Lord Kixdemp11-Feb-06 7:27
Lord Kixdemp11-Feb-06 7:27 
GeneralRe: Writing std::string to a binary file? Pin
Ravi Bhavnani11-Feb-06 7:33
professionalRavi Bhavnani11-Feb-06 7:33 
GeneralRe: Writing std::string to a binary file? Pin
Lord Kixdemp11-Feb-06 8:08
Lord Kixdemp11-Feb-06 8:08 
GeneralRe: Writing std::string to a binary file? Pin
Ravi Bhavnani11-Feb-06 8:11
professionalRavi Bhavnani11-Feb-06 8:11 
QuestionDetecting Internet connection Pin
Healdp11-Feb-06 0:53
Healdp11-Feb-06 0:53 
AnswerRe: Detecting Internet connection Pin
Taka Muraoka11-Feb-06 2:07
Taka Muraoka11-Feb-06 2:07 
AnswerRe: Detecting Internet connection Pin
bob1697211-Feb-06 2:49
bob1697211-Feb-06 2:49 
GeneralRe: Detecting Internet connection Pin
Healdp11-Feb-06 4:04
Healdp11-Feb-06 4:04 
GeneralRe: Detecting Internet connection Pin
bob1697211-Feb-06 5:05
bob1697211-Feb-06 5:05 
GeneralRe: Detecting Internet connection Pin
Healdp12-Feb-06 1:22
Healdp12-Feb-06 1:22 
GeneralRe: Detecting Internet connection Pin
bob1697211-Feb-06 5:26
bob1697211-Feb-06 5:26 
GeneralRe: Detecting Internet connection Pin
Healdp11-Feb-06 5:45
Healdp11-Feb-06 5:45 
GeneralRe: Detecting Internet connection Pin
bob1697211-Feb-06 6:13
bob1697211-Feb-06 6:13 
GeneralRe: Detecting Internet connection Pin
Sunil P V7-Mar-07 19:35
Sunil P V7-Mar-07 19:35 
AnswerRe: Detecting Internet connection Pin
PJ Arends11-Feb-06 6:10
professionalPJ Arends11-Feb-06 6:10 
AnswerRe: Detecting Internet connection Pin
Ravi Bhavnani11-Feb-06 7:01
professionalRavi Bhavnani11-Feb-06 7:01 

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.