Click here to Skip to main content
15,891,431 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionConnected or not? Pin
wasife20-Feb-05 18:58
wasife20-Feb-05 18:58 
AnswerRe: Connected or not? Pin
ThatsAlok20-Feb-05 19:11
ThatsAlok20-Feb-05 19:11 
AnswerRe: Connected or not? Pin
David Crow21-Feb-05 4:10
David Crow21-Feb-05 4:10 
AnswerRe: Connected or not? Pin
Michael Dunn21-Feb-05 6:58
sitebuilderMichael Dunn21-Feb-05 6:58 
GeneralTitle bar Color Pin
Anonymous20-Feb-05 18:54
Anonymous20-Feb-05 18:54 
QuestionHow to fix first four coumns of the List ctrl and all other columns to allow scrolling Pin
sureshpillai20-Feb-05 18:40
sureshpillai20-Feb-05 18:40 
GeneralPassing values of object. Getting garbage. Pin
macrophobia20-Feb-05 18:25
macrophobia20-Feb-05 18:25 
GeneralRe: Passing values of object. Getting garbage. Pin
David Nash20-Feb-05 22:02
David Nash20-Feb-05 22:02 
It's difficult to see what the problem might be without seeing more of your source code. Anyway, here is a short program which does something like what you're after (I think).

/////////////////////////////////////////////////

#include <iostream>
#include <fstream>
#include <string>

using namespace std;


void dataOut(string foodName, int Calor, double wtr)
{
ofstream out("MyFile");
out << foodName << endl << Calor << endl << wtr;
}

void dataIn(string foodName, int Calor, double wtr)
{
ifstream in ("MyFile");
in >> foodName >> Calor >> wtr;
cout << "Food: " << foodName << endl<<
"Calories: " << Calor << endl <<
"Wtr: " << wtr << endl;
}

class FileData
{
public:
string strFood;
int intCalor;
double dblFat;

FileData() : strFood("Cakes"), intCalor(1000),
dblFat(2.2222){};
};


int main()
{
FileData breadobject;

dataOut(breadobject.strFood, breadobject.intCalor,
breadobject.dblFat);

dataIn(breadobject.strFood, breadobject.intCalor,
breadobject.dblFat);

return 0;
}

//////////////////////////////////////////////

Hope this helps,
David

GeneralRe: Passing values of object. Getting garbage. Pin
macrophobia20-Feb-05 23:43
macrophobia20-Feb-05 23:43 
GeneralRe: Passing values of object. Getting garbage. Pin
David Nash21-Feb-05 3:10
David Nash21-Feb-05 3:10 
GeneralUPDATE - Passing values.Getting garbage. Pin
macrophobia21-Feb-05 2:01
macrophobia21-Feb-05 2:01 
GeneralRe: UPDATE - Passing values.Getting garbage. Pin
David Nash21-Feb-05 3:32
David Nash21-Feb-05 3:32 
GeneralRe: UPDATE - Passing values.Getting garbage. Pin
David Nash21-Feb-05 12:19
David Nash21-Feb-05 12:19 
GeneralRe: UPDATE - Passing values.Getting garbage. Pin
macrophobia21-Feb-05 15:44
macrophobia21-Feb-05 15:44 
GeneralRe: UPDATE - Passing values.Getting garbage. Pin
macrophobia21-Feb-05 16:25
macrophobia21-Feb-05 16:25 
GeneralRe: UPDATE - One final suggestion Pin
David Nash22-Feb-05 2:31
David Nash22-Feb-05 2:31 
GeneralInsert a dialog in MDI!! Pin
20-Feb-05 18:12
suss20-Feb-05 18:12 
GeneralRe: Insert a dialog in MDI!! Pin
Aamir Butt20-Feb-05 22:06
Aamir Butt20-Feb-05 22:06 
GeneralRe: Insert a dialog in MDI!! Pin
Maximilien21-Feb-05 0:30
Maximilien21-Feb-05 0:30 
GeneralEnabling HotKeys in an MFC based application Pin
PrashantJ20-Feb-05 17:47
PrashantJ20-Feb-05 17:47 
GeneralRe: Enabling HotKeys in an MFC based application Pin
ThatsAlok20-Feb-05 19:10
ThatsAlok20-Feb-05 19:10 
GeneralRe: Enabling HotKeys in an MFC based application Pin
22491720-Feb-05 19:37
22491720-Feb-05 19:37 
GeneralA Simple Problem Pin
SeanSheehan20-Feb-05 17:46
SeanSheehan20-Feb-05 17:46 
GeneralRe: A Simple Problem Pin
22491720-Feb-05 18:32
22491720-Feb-05 18:32 
GeneralRe: A Simple Problem Pin
SeanSheehan20-Feb-05 20:26
SeanSheehan20-Feb-05 20:26 

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.