|
-
Jul 31st, 2001, 11:08 AM
#1
Thread Starter
Frenzied Member
2 C++ ??: 1) a Val() equivalent? 2) a conversion list?
Hi all.
I am just beginning my study of (Visual) C++ this week. I was re-writing a calculator I wrote in VB when I was just begiinning VB.
So is there a C++ equivalent to Val() ?
I found strtod(a,b) which seems to be the equivalent of
vb's Cdbl(x) .
Anyway, I can't get strtod to work. I just don't get it and the MSDN example doesn't make sense.
So I have a string with a numerical value like "500"
and I want to move that to a double like
dblNumber = strtod(strNumber,????)
and everything I put in the 2nd parameter creates errors.
Okay, 2nd question, is there a place I can find a keyword (key function) conversion list for VB and C++? I think that would help the most.
Thanks all.
Wengang
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
-
Jul 31st, 2001, 11:25 AM
#2
Frenzied Member
Try declaring the numerical variable as an integer 
-
Jul 31st, 2001, 01:36 PM
#3
transcendental analytic
So is there a C++ equivalent to Val() ?
probably not. Val does many other opererations besides converting unicode strings to variant numeric datatypes
Okay, 2nd question, is there a place I can find a keyword (key function) conversion list for VB and C++? I think that would help the most.
many vb functions doesn't exist in c++, however there are libraries with algoritms that perform more specific actions.
i think you have to pass a double pointer in ???? place, if you declare a double x, you pass &x
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 28th, 2001, 07:39 AM
#4
ad 1:
The second param is of type char **ppEndPtr. This means it's a pointer to a pointer to a character. This works the following way:
Pass the string "347.28aiw" to strtod. The function will extract 347.28 and stop at the 'a', since it is not a number. The function will the set the *ppEndPtr to the 'a', so you know afterwards until where the function did read the string. You can either pass NULL or like this:
char* str = "279.18aiw";
char* pEndChar;
double val = strtod(str, &pEndChar);
ad 2:
You can always ask us if you need a funciton equivalent.
All the buzzt
CornedBee
-
Aug 28th, 2001, 08:24 AM
#5
Frenzied Member
Well yes there are some VB functions that don't exist in C++ but they call all be improvised.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|