|
-
Nov 1st, 2002, 06:42 PM
#1
Thread Starter
Hyperactive Member
long to char ***Resolved
I know this has probably been asked a thousand times, and I've searched all through the forums and I'm still getting errors..
Code:
char Space[255];
long lNumber;
lNumber = 223538;
I've tried
Code:
sprintf(space, "%i", (int)lNumber);
itoa((int)lNumber, space, 10)
*(long*)space=lNumber;
And from what I can work out, they either do nothing, or are converting the number into actual ascii characters. I simply want
Space = "232538";
as such.
Thanx
Last edited by Wak; Nov 2nd, 2002 at 08:47 PM.
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Nov 1st, 2002, 06:55 PM
#2
Good Ol' Platypus
I use ostringstream:
PHP Code:
char buffer[10];
ostringstream mstr(buffer, 10);
long lNumber;
lNumber = 223538
mstr << lNumber << ends;
cout << mstr.str() << endl;
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Nov 1st, 2002, 07:50 PM
#3
Thread Starter
Hyperactive Member
hey
I don't know if this will make a difference for you, but I'm not writing a console mode application hey.. 
I haven't actually tested it, but I notice that a lot of the console mode stuff doesn't work when creating Win Apps (only in regards to the variables that can be declared)
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Nov 1st, 2002, 08:08 PM
#4
Frenzied Member
Re: hey
Originally posted by Wak
I don't know if this will make a difference for you, but I'm not writing a console mode application hey.. 
I haven't actually tested it, but I notice that a lot of the console mode stuff doesn't work when creating Win Apps (only in regards to the variables that can be declared)
Itll work, unless you are doing something wrong.
Z.
-
Nov 1st, 2002, 08:10 PM
#5
Frenzied Member
-
Nov 1st, 2002, 08:40 PM
#6
Good Ol' Platypus
Only thing for console mode there is cout, the oss is just used like it.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Nov 1st, 2002, 09:19 PM
#7
Thread Starter
Hyperactive Member
mmm
if i use _itoa and 10 for the 3rd parameter, the number is too big, base 10 is tooo low...
and if I use _itoa with 16 for the 3rd parameter, then the number has all the letters that come with base 16...
How can I just get 223538 in the string?? which base??
also with hostringstream, are there any specific files that i need to include??
thanx
Visual Basic 6.0 Enterprise
Visual C++ 6.0 Professional
Wak 
-
Nov 2nd, 2002, 07:16 AM
#8
transcendental analytic
use base 10, base in a numbering system is the times a digit is worth its digit to the right, the alphabet starting from A are used as digits beyond 9.
Do you have at least 7 chars in your buffer? can you show your code?
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.
-
Nov 2nd, 2002, 11:35 AM
#9
Good Ol' Platypus
Yes, for ostringstream you must include <sstream>,
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Nov 2nd, 2002, 08:47 PM
#10
Thread Starter
Hyperactive Member
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
|