|
don't use atoi(). instead use atof()
I think you must read the documentation rather than starting to build on the project. atoi converts a string to int and not to a float and then when you add them it returns an int in uSum which is just printed as a float value.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
ok but... :
uSum += atof( csText);
warning C4244: '+=' : conversion from 'double' to 'int', possible loss of data
Why?
Bravoone
|
|
|
|
|
because nSum has data type int.
|
|
|
|
|
uSum is an int. so you would need to use typecasting or declare uSum as a float.
I think you are missing on the basics.
Bravoone_2006 wrote: ok but... :
uSum += atof( csText);
warning C4244: '+=' : conversion from 'double' to 'int', possible loss of data
It would be better if you read some tutorials on typecasting, using variables and reading some more basics and some more............................and a few more....................
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Bravoone_2006 wrote: Why?
You declare an integer, how would you expect to store a floating point value into it and expect that it still holds a floating point value ? I think you REALLY need to find some good book about the basics of C++. I mean, knowing what an integer and a double are, is at least the bare minimum. It's the thing you learn at very very begining.
|
|
|
|
|
WTF !!! can't you understand the error message ??????
Bravoone_2006 wrote: warning C4244: '+=' : conversion from 'double' to 'int' , possible loss of data
to int mean you're writing in an int !
you know what ? go by a C/C++ book and learn that language biefore trying to use it any further (or swith to VB )
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
_AnShUmAn_ wrote: I think you must read the documentation rather than starting to build on the project
no, you forget the prerequisite step : learn C++
this guy is f*cking too lazy and keeps asking since months now dumb questions
|
|
|
|
|
|
you must declare uSum as float. and atof() instead of atoi().
<br />
float nSum = 0;<br />
float uSum = 0;<br />
|
|
|
|
|
Dude - take a class or buy a book.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
thanks for your valueable answer. can you give me a working code in this regard please ?
|
|
|
|
|
How would he do that?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I don't know why, but this guys is really starting to piss me off. I spent almost an hour writing my response to him a few threads down, assuming he was at least semi-capable as a C++ programmer.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: I don't know why, but this guys is really starting to piss me off.
Is there anything that doesn't, John? How people can get so riled over stuff like this is beyond me. If he bothers you so, why not just ignore him and move on?
John Simmons / outlaw programmer wrote: I spent almost an hour writing my response to him a few threads down, assuming...
That was your second mistake.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi all:
Having a bit problem here. The function signature is as following:
<code>OccurrenceList& getOccurrences(string word);</code>
Seems to me, it reads the function "getOccurrences" will return a reference which refers to a variable of "OccurrenceList" type. Am I right?
Thank you
|
|
|
|
|
Yes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi:
If that is right, why am I always getting this error:"error C2143: syntax error : missing ';' before '&'".
The function definition is:
<code>OccurrenceList& WordTable::getOccurrences(string theWord) "<-The line of error".
{
return; //It returns nothing because I want to simplify the function first. I know it will generate another error.
}</code>
Can anyone help?
Thank you
|
|
|
|
|
Maybe OccurrenceList is not recognized as a type. Check it about.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
C_Zealot wrote: error C2143: syntax error : missing ';' before '&
you probably forgot to #include the header in which the OccurrenceList class is defined...
C_Zealot wrote: return; //It returns nothing because I want to simplify the function first. I know it will generate another error
also, for this, i'd suggest you to prefer this, even if it's temporary and returns a reference to a local variable :
return OccurrenceList();
|
|
|
|
|
hi all
i hane made a dialog box in mfc and a button on it
i set browse on button
how can i browse a word document and attach it with it
please help me
bye
hi
|
|
|
|
|
Use CFileDialog() or SHBrowseForFolder API.
paras_s12 wrote: how can i browse a word document and attach it with it
To what do you want to attach the WORD doc to
"it" is just not self explanatory and what do you exactly mean by attaching it.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
paras_s12 wrote: ...browse a word document...
paras_s12 wrote: attach it with it
"It" being what?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello
I have a strange problem in my code. I call this function to return me the current date and time. But, what I have observed is that once this piece of code gets exceuted in my workspace, all the CString variables in the workspace get initialized with the current date time by default (though they have been intialized with empty strings)
Is this because of the concept called buffer overrun. Is there anything like buffer overrun happening here where in the memory is getting corrupted because we are not specifying the size of the source / target buffers into which the strings have to be copied.
Please do clarify. Find the code snippet attached.
<br />
CString CLogger::GetCurrentDateTime()<br />
{<br />
CString strCurrDateTime,strTemp;<br />
<br />
SYSTEMTIME stCurrent,stLocal;<br />
GetSystemTime(&stCurrent); <br />
SystemTimeToTzSpecificLocalTime(NULL, &stCurrent, &stLocal);<br />
<br />
<br />
wsprintf(strCurrDateTime.GetBuffer(0),_T("%02d/%02d/%d %02d:%02d"),stLocal.wDay, stLocal.wMonth, stLocal.wYear,stLocal.wHour, stLocal.wMinute);<br />
<br />
return strCurrDateTime;<br />
}<br />
Regards,
Vipin.
|
|
|
|
|
Never use GetBuffer for doing things like that (and furthermore, you request a size of 0, so you will probably screw everything by write something much larger in the buffer). See the doc[^]
You should use the Format[^] function instead.
|
|
|
|