|
That's because atof returns a float (guess what the 'f' in the function name stands for ?). You could try by using stringstream from the STL:
stringstream ssVal;
double dValue;
ssVal << pszValue;
ssVal >> dValue;
Don't forget to #include <sstream> and to put using namespace std; at the top of your cpp file.
Forget what I say, I wasn't awake . If you look at the range of a double, you'll see that the accuracy (here)[^] is 14 or 15 digits. Your string contains much more digits than that. Now, if the number that you want to represent is an integer value, why don't you use an __int64 instead ?
But, I have a question: why do you need such an accuracy, why is it important ? In most of the cases, you won't need that accuracy.
|
|
|
|
|
Cedric Moonen wrote: That's because atof returns a float
yeah that's what I thought about too. Until I saw this in MSDN[^]. Why not name it atod in the first place?
|
|
|
|
|
Yeah, I realized that just after I posted. I updated my answer already.
|
|
|
|
|
Hello,
I have created one MFC Application for User login page. I have created 2 dialog boxes. One dialog box contains username and password, when i press Create new account button, there is another dialog box will open. There i have given the username, password and confirm password.
The problem is if i click the submit button in 2nd dialog, only one character has to be stored in the file.
I want to store the entire text in the file.
How can I do that?. Please help on this.
Thanks in advance.
|
|
|
|
|
can you paste the code on that part? so we will know what the error is.
|
|
|
|
|
Hello,
Thanks a lot for reply. I attached the source code below:
If i click the submit button the following code is executing.
--------------------------------------------------------------
FILE *fleCredentials;
try {
// Create a new file or open the existing one
fleCredentials = fopen("credentials.crd", "a+");
{
// Add the username to the file
//
fprintf(fleCredentials, "%s ", (LPCTSTR)m_Username);
// Add the password to the file
fprintf(fleCredentials, "%s\n", (LPCTSTR)m_Password);
}
// After using it, close the file
fclose(fleCredentials);
--------------------------------------------------------
|
|
|
|
|
What is the data type of m_Username and m_Password?
|
|
|
|
|
m_username and m_password are CString types.
|
|
|
|
|
If you use the debugger at that function to save the two files, I bet you get...
m_User = "user" and m_Pass = "pass" (I can't see your original code)
And then your text file will be....
userpass
with no way of know where one starts, and the other finishes...
Instead of CString, try using a fixed character array, and then saving that out. It will be much easier when you load it. It will have the restriction of only being able to have user names and passwords of a certain length, so don't make it too short!
Iain.
|
|
|
|
|
Try using GetBuffer() function for the CString objects in the fprintf statement?
|
|
|
|
|
No, don't do that at all. The GetBuffer() method should only be used when write access to the internal buffer is required. In this case, it is not. The LPCTSTR operator is all that's needed.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How are you verifying that only two characters (one from each variable) exist in the file? Is this a Unicode application?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Could you please post the code snippet ?
Regards,
Paresh.
|
|
|
|
|
I have given the code snippet where i can get the problem.
|
|
|
|
|
How to edit subitems in a list view , i tried LVS_EDITLABELS but it allows to edit first column only.
Thanks & Regards
|
|
|
|
|
Have you tried SetItemText ?
|
|
|
|
|
There is not provision in list control for doing this. U have to create your own edit control and manage it. You can find many samples in code project itself. Search.....
|
|
|
|
|
Hi All,
I have one requirement wherein the user does not want to install Winzip and use WinXP's in build de/compression utlity. Is there any way to call "Extract ALL" from Command line.Ealier i wan executing a simple winzip command from command line to achieve the same.
Thanks in Advance,
Abhi Lahare
|
|
|
|
|
type zip -? in command line to find out the commands available
|
|
|
|
|
i have a combo box which contains interger values and i have couple of files in my application. i have mapped this combo box to integer. i am getting the index of the value and i am using cstring to convert it to the original value. for ex. there are 2 values in my combo box. 100 and 200. if i select 100 i get the index as 0. and the CString variable will return the value(100). now my requirement is i need to pass the value(100) to another file. how do i do it?
|
|
|
|
|
You can write get/set function and then using class pointer access those values in another file.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
is there any other way other than that?
|
|
|
|
|
If your classes support parent/child relationship then you can use GetParent() from your child class to access the members of the parent.
(P.S. - Is there some problem in getting the values as per my previous suggestion.)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
there is no problem in doing so. but thought the other way where u make an instance of a class and pass the value thru that.
|
|
|
|
|
as a constructor parameter for instance...
|
|
|
|