Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Smack0007

String Manipulation Question

This topic is 6683 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, in the Win32 Enviroment, you can get two things from an Edit Box: a string, and an int (GetDlgItemText() & GetDlgItemInt()). How would you get a double or a float? Im pretty sure you have to do something like extract a string and convert it somehow but I have not been able to figure it out yet. zac@qisfl.net
Snowsoft Online
I don't pretend to know anything. Edited by - Smack0007 on 8/26/00 1:15:08 PM Edited by - Smack0007 on 8/26/00 1:16:23 PM

Share this post


Link to post
Share on other sites
Advertisement
if you can get a string of your number, all you need it the ATO family
Just look in your help files for the ato* functions.
atoi converts alpha to integer (hence the ATOI)
atof should convert from alpha to float, if I am not totally mistaken ?

youpla :-P

Share this post


Link to post
Share on other sites
actually a "LPSTR" is the same thing as "const char *". long pointer to string which: a string is an array of char''s. which is the same thing as "char *". just explicitly cast it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
How r u doing the code?
I would do:

char * afloat;
float float;
int length;

//Can''t remeber off hand all the params to the functions
length= GetWindowTextLength(GetDlgItem(MAKEINTRESOURCE(TEXT_BOX))
//or sominthing, just get the length of the text
afloat = (char *)malloc(sizeof(char)*length+1));

GetDlgItemText(TEXT_BOX, afloat, length);
//once again can''t remeber params
afloat[length+1] = ''\0'';

float = atof(afloat);

//-------------------
Thats off the top of my head, and with out anything
to look up its acuracy.
Evan,
evan@achaia.dircon.co.uk

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!