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

C / C++ / MFC

 
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 
GeneralRe: Passing values of object. Getting garbage. Pin
macrophobia20-Feb-05 23:43
macrophobia20-Feb-05 23:43 
Thank you very much for the response. Unfortunately, my problem is unchanged. Frown | :(

Sorry if my question is vague.

To clarify: I only need to save these values to the file.

It is reassurring to see that you are using the same method that I have for passing the values to the ofstream. Notice that portion in the code below.

The function definition and function call (with arguments) are as previously posted and as you have described.

Now I am beginning to think that the problem does not exist in the
function call --> function --> file open and output.

Rather, I am beginning to think the problem lies in the:
assigning values --> function call --> function

Please, take a look at the way I am assigning the values prior to handing them to the function call as arguments.

-snip-

//from bread.h

class Bread <br />
{<br />
public:<br />
<br />
void setValues(double fat,double carb,int calor,double fiber);<br />
<br />
std::string strFileName;<br />
double dblFat;<br />
double dblCarb;<br />
double dblFiber;<br />
int intCalor;<br />
};



//from Bread.cpp
<br />
void dataOut(std::string foodName, int Calor, double wtr, double prt, double fat,double carb,double fib,double vita,double vitb, double vitc, double calci)<br />
{<br />
	std::fstream<br />
		appendFile("Tally.txt");<br />
	<br />
<br />
	if(!appendFile.is_open())<br />
	{<br />
		std::ofstream<br />
			outputFile("Tally.txt");<br />
<br />
	if(!outputFile.is_open())<br />
	{<br />
		std::cerr << "\nNot enough memory to create file\n";<br />
		exit(1);<br />
	}<br />
		else<br />
		{<br />
			outputFile << << "\n\nFood: "<< foodName << "\n"<br />
			<< "Calories: "<< Calor << "\n"<br />
			<< "Water (oz): "<< wtr << "\n"<br />
			<< "Protein: "<< prt << "\n"<br />
			<< "Fat: "<< fat << "\n"<br />
			<< "Carbohydrates: "<< carb << "\n"<br />
			<< "Fiber: "<< fib << "\n"<br />
			<< "Vitamin A: "<< vita << "\n"<br />
			<< "Vitamin B: "<< vitb << "\n"<br />
			<< "Vitamin C: "<< vitc << "\n"<br />
			<< "Calcium: "<< calci << "\n";<br />
}<br />
                 }<br />
              	else<br />
	{<br />
	appendFile.seekp(0,std::ios::end);//places cursor to end of file<br />
<br />
	appendFile << "\n\nFood: "<< foodName << "\n"<br />
		<< "Calories: "<< Calor << "\n"<br />
		<< "Water (oz): "<< wtr << "\n"<br />
		<< "Protein: "<< prt << "\n"<br />
		<< "Fat: "<< fat << "\n"<br />
		<< "Carbohydrates: "<< carb << "\n"<br />
		<< "Fiber: "<< fib << "\n"<br />
		<< "Vitamin A: "<< vita << "\n"<br />
		<< "Vitamin B: "<< vitb << "\n"<br />
		<< "Vitamin C: "<< vitc << "\n"<br />
		<< "Calcium: "<< calci << "\n";<br />
	}<br />
}<br />
<br />
int main()<br />
{<br />
breadobject.setValues( 1.1 , 11.4 , 60 , 0.9 );<br />
breadobject.strFileName="White Slice";<br />
<br />
dataOut(breadobject.strFileName, breadobject.intCalor, 2.2, 0.0, breadobject.dblFat, breadobject.dblCarb, breadobject.dblFiber, 0.0, 0.0, 0.0, 0.0); /*remember, this part is working ok*/<br />
<br />
return 0;<br />
}


WTF | :WTF:
WHEW!
Travis
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 
GeneralRe: A Simple Problem Pin
Jetli Jerry20-Feb-05 20:59
Jetli Jerry20-Feb-05 20:59 

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.