|
-
Jul 21st, 2001, 06:41 AM
#1
Thread Starter
Hyperactive Member
Number to String
This has been asked millions of times before, I'm sure, but how do I turn a unsigned integer into a string, I'm using _utloa() function but it's not working. Am I doing something wrong?
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Jul 21st, 2001, 07:54 AM
#2
Frenzied Member
Just use the itoa function. See the FAQ for an example.
-
Jul 21st, 2001, 08:28 AM
#3
Thread Starter
Hyperactive Member
whoops
I made a huge mistake in my 1st post, I mean an unsigned long into a string. I use the _utloa() and I get '!!!!!!!!!' or similar returned.
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Jul 21st, 2001, 09:35 AM
#4
USe the sprintf() or wsprintf() functions.
Code:
int n = 45;
LPSTR lpNum;
wsprintf(lpNum, "%d", n);
-
Jul 21st, 2001, 10:38 AM
#5
Monday Morning Lunatic
You need a real buffer, not just a pointer:
Code:
char pcBuf[10];
sprintf(pcBuf, "%d", number);
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jul 21st, 2001, 06:50 PM
#6
Thread Starter
Hyperactive Member
I can't get it
From this code
Code:
char szSectors[10];
sprintf(szSectors, "%i", 10);
puts(szSectors);
I'm getting ìììììììììììììììììììì in the szSectors
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Jul 21st, 2001, 06:57 PM
#7
Monday Morning Lunatic
I just tried that exact code and it printed "10"
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jul 21st, 2001, 07:07 PM
#8
Thread Starter
Hyperactive Member
hmm
Are we talking Console applications or
Windows Applications???
Does it matter??
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Jul 21st, 2001, 07:13 PM
#9
Thread Starter
Hyperactive Member
Sorry posting heaps....
ok. I'm getting 10ìììììììì now, is there a way to cut off the ììììììì's?
edited:
I'm being stupid now, I got it.
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Jul 22nd, 2001, 08:48 PM
#10
PowerPoster
try this...
char szSectors[10];
memset(szSectors, 0, 10);
sprintf(szSectors, "%i", 10);
puts(szSectors);
or
char szSectors[10]=NULL;
sprintf(szSectors, "%i", 10);
puts(szSectors);
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
|