Click here to Skip to main content
15,926,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Warning for conversion from double to int Pin
CPallini8-Jan-07 21:11
mveCPallini8-Jan-07 21:11 
GeneralRe: Warning for conversion from double to int Pin
prasad_som8-Jan-07 21:23
prasad_som8-Jan-07 21:23 
QuestionHELP! About COleDateTime Pin
kcynic8-Jan-07 15:44
kcynic8-Jan-07 15:44 
AnswerRe: HELP! About COleDateTime Pin
Stephen Hewitt8-Jan-07 16:41
Stephen Hewitt8-Jan-07 16:41 
QuestionRe: HELP! About COleDateTime Pin
prasad_som8-Jan-07 16:58
prasad_som8-Jan-07 16:58 
AnswerRe: HELP! About COleDateTime Pin
kcynic8-Jan-07 17:15
kcynic8-Jan-07 17:15 
QuestionRe: HELP! About COleDateTime Pin
prasad_som8-Jan-07 17:21
prasad_som8-Jan-07 17:21 
Questionifstream - saving classes [modified] Pin
Dosin8-Jan-07 13:53
Dosin8-Jan-07 13:53 
I have created a class file and class header- in the header I save version,file name, and # of last file saved
then everything after that is the file storage.. The problem I am having is: my index has a bug-

reading the file:
file k[150];
		
header hdrs;
ifstream op("file.dat",ios::nocreate);

op.read(reinterpret_cast <char*> (&hdrs),sizeof(header));

op.read(reinterpret_cast <char*> (&k),hdrs.index * sizeof(file));

saving the file:

strcpy(k[hdrs.index].first_name,s);
m_last.GetWindowText(f);
strcpy(k[hdrs.index].last_name,f);
ofstream fi("file.dat",ios::nocreate);

	if(!fi.is_open())
	{
		MessageBox("File failed!","",MB_OK);
	}
		
hdrs.index++;
	
s.Format("File Storage system");
	
strcpy(hdrs.title,s);
s.Format("1.0");
strcpy(hdrs.version,s);
fi.seekp(0,ios::cur);
fi.write(reinterpret_cast <char*> (&hdrs),sizeof(header));
	
fi.write(reinterpret_cast <char*> (&k),hdrs.index * sizeof(file));
	
fi.close();


after saving a number of data items the index looses count and gives me a number:-858993460

It works sometimes for a while before loosing count and other times right off the start..

any ideas why?








-- modified at 20:15 Monday 8th January, 2007
AnswerRe: ifstream - saving classes Pin
Stephen Hewitt8-Jan-07 14:13
Stephen Hewitt8-Jan-07 14:13 
GeneralRe: ifstream - saving classes Pin
Dosin8-Jan-07 14:19
Dosin8-Jan-07 14:19 
GeneralRe: ifstream - saving classes [modified] Pin
Dosin8-Jan-07 14:43
Dosin8-Jan-07 14:43 
AnswerRe: ifstream - saving classes Pin
Stephen Hewitt8-Jan-07 15:35
Stephen Hewitt8-Jan-07 15:35 
GeneralRe: ifstream - saving classes Pin
Dosin8-Jan-07 16:15
Dosin8-Jan-07 16:15 
GeneralRe: ifstream - saving classes Pin
Stephen Hewitt8-Jan-07 16:47
Stephen Hewitt8-Jan-07 16:47 
General[Message Deleted] Pin
Dosin8-Jan-07 16:58
Dosin8-Jan-07 16:58 
GeneralRe: ifstream - saving classes Pin
prasad_som8-Jan-07 17:09
prasad_som8-Jan-07 17:09 
GeneralRe: ifstream - saving classes Pin
Dosin8-Jan-07 17:28
Dosin8-Jan-07 17:28 
GeneralRe: ifstream - saving classes Pin
Stephen Hewitt8-Jan-07 17:14
Stephen Hewitt8-Jan-07 17:14 
GeneralRe: ifstream - saving classes Pin
Dosin8-Jan-07 17:36
Dosin8-Jan-07 17:36 
GeneralRe: ifstream - saving classes Pin
Stephen Hewitt8-Jan-07 17:53
Stephen Hewitt8-Jan-07 17:53 
GeneralRe: ifstream - saving classes Pin
Dosin8-Jan-07 18:10
Dosin8-Jan-07 18:10 
QuestionCheckbox? Pin
Larsson8-Jan-07 8:23
Larsson8-Jan-07 8:23 
QuestionRe: Checkbox? Pin
David Crow8-Jan-07 8:27
David Crow8-Jan-07 8:27 
AnswerRe: Checkbox? Pin
Larsson8-Jan-07 8:53
Larsson8-Jan-07 8:53 
GeneralRe: Checkbox? Pin
David Crow8-Jan-07 9:01
David Crow8-Jan-07 9: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.