flat assembler
Message board for the users of flat assembler.

Index > Windows > how to convert int/string float/string and vice versa

Author
Thread Post new topic Reply to topic
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1 12 Jan 2008, 07:19
Is there a way under Windows API to convert from int/float to string and vice versa?
Don't tell me about msvcrt.dll functions like *scanf, *printf, ato* etc.

_________________
Code:
 o__=-
 )
(\
 /\  
    
Post 12 Jan 2008, 07:19
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 12 Jan 2008, 11:59
wtf?

first you ask something, and then you say not to tell you the answer?
Post 12 Jan 2008, 11:59
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1 12 Jan 2008, 12:01
simply because those function are defined by C standard!
i wanted to know if there are windows api specifics?
Post 12 Jan 2008, 12:01
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 12 Jan 2008, 12:37
yes, microsoft did lot of custom libc-like functions
Post 12 Jan 2008, 12:37
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4020
Location: vpcmpistri
bitRAKE 12 Jan 2008, 12:59
What is it you are trying to avoid? Including runtime DLL, or the C-like interface? The API has functions like wsprintf which will do the conversion and user32 is very likely to be mapped into address space. kernel32 has string functions as well.
Post 12 Jan 2008, 12:59
View user's profile Send private message Visit poster's website Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1 12 Jan 2008, 13:13
well ... for example the scanf is defined by C standard so it should be there but can not use full platform support!
what I was looking (at least hoping) for was any particular conversion function in
the API itself (different from C functions).
I was wondering if I could find more powerful (having more control maybe) functions in the API.

Take a simple example:
I use:
scanf("%d", &num);

but user enters:
abcd

now scanf() can't manage that very well!

so may be an API function is there which would plain reject (and may be beep as well) all the other data except one which it was supposed to read!

I made and earlier post seeking for an API specific function to read from kbd.
I was hoping to find a function that would allow some more editing features besides just the back space!
Post 12 Jan 2008, 13:13
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 12 Jan 2008, 13:20
Quote:
now scanf() can't manage that very well!

What it can't manage so well about it? You just have to learn how to use it.

There is one thing that scanf doesn't manage well for some reason though - overflows.
Post 12 Jan 2008, 13:20
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1 12 Jan 2008, 13:22
i expected an integer!
user enters a string!

go figure! what scanf can't handle!
Post 12 Jan 2008, 13:22
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 12 Jan 2008, 13:29
again.. what doesn't scanf() handle about it? what should it do differently?
Post 12 Jan 2008, 13:29
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1 12 Jan 2008, 13:35
OMG!
why don't you understand?
scanf will return me wrong data!
but if some function existed that would not allow me type anything besides digits ...

and it's possible if i use API features I guess!
may god help me!
Post 12 Jan 2008, 13:35
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4020
Location: vpcmpistri
bitRAKE 12 Jan 2008, 13:39
0.1, yeah - that is a problem. Best use an edit control that is limited to numbers, or you'll have to loop for user to re-enter or cancel.
Post 12 Jan 2008, 13:39
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 12 Jan 2008, 13:42
Quote:
scanf will return me wrong data!

scanf returns perfectly valid result, it's just that you can't use it properly.

Before trying to use some function, study how to use it:
http://msdn2.microsoft.com/en-us/library/9y6s16x1(VS.71).aspx

Quote:
but if some function existed that would not allow me type anything besides digits ...

You don't understand how streams work. "scanf" doesn't have any control over the code which handles console input. There may be no console at all, and STDIN can be redirected from file.
Post 12 Jan 2008, 13:42
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1 12 Jan 2008, 13:46
whatever the doo-hee-kee you said vid!
i know scanf has no control coz stdin can be blah blah blah
that's exactly why i am looking for a replacement from api!

i would post my code (that would not allow invalid data (on console!)) in an hour or so ...
but i don't have pc at home and i can't do this at work!
Post 12 Jan 2008, 13:46
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 12 Jan 2008, 13:59
Quote:
that's exactly why i am looking for a replacement from api!

There is no such function... it would be pretty stupid idea, and it will fail in case there is no console. You can write such function yourself, but it won't be so trivial, and there is no point in doing it. Instead, check if user entered valid number, and if not, display error
Post 12 Jan 2008, 13:59
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 12 Jan 2008, 20:31
Maybe he wanted atoi() itoa() ^o) Aren't they Uindooze Very Happy
Post 12 Jan 2008, 20:31
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 14 Jan 2008, 01:14
Okay, I've seen a getch() good-looking loop that would, upon entering a number/character, immediately print a * in the position. It works so fast under C that you couldn't tell, so that would work for you?? Just use getch() in a pretty loop?? I use it all the time for pauses in my prgms, either that or submit to using the vas array of C RUNTIME LIBRARIES THAT COME WITH WINDOWS IN THE FIRST PLACE!!! Don't be die hard because those functions in the C library are part of Windows API, u are the one not getting it.
Post 14 Jan 2008, 01:14
View user's profile Send private message Visit poster's website Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1 14 Jan 2008, 06:28

_________________
Code:
 o__=-
 )
(\
 /\  
    
Post 14 Jan 2008, 06:28
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.