I have an integer and I want to convert it into char but keeping its value!! !!!
How to do that?
I have an integer and I want to convert it into char but keeping its value!! !!!
How to do that?
Last edited by Bong.Da.City; 22nd December 2010 at 18:41.
Have a look here: http://lmgtfy.com/?q=int+to+char!
i google it but what i found didn't work... anyway delete the post because you do not want to answer
What you are asking for is impossible. Ints hold bigger numbers that chars, unless you are working on a system where the sizeof(int) is the same as sizeof(char).
What are you trying to do?
Most compilers accept the itoa(...) function
Special trained in understanding questions, he wants:But as told: google is nice to you if you ask it or simply grab the documentation for Qt and start with the QString documentation.Qt Code:
char *c; int i = 12345; // here do the magic here with i and c. cout << c; // this should print: 12345.To copy to clipboard, switch view to plain text mode
In addition to the above, C++ stringstreams solve this problem nicely.
Assuming the problem has been interpreted correctly. It's really impossible to decipher the original post.
It is always funny how on forums people tell you to Google something. When in fact Google returns this as the first result and usually results for other things.
Ah, but you see this is an example of metahistory. At the time of the original post, this post didn't exist in Google's list of results. So if you click on the lmgtfy link in Lykurg's first reply, you pass through a wormhole and emerge into an alternative universe where the future is known in the past, because now this post appears in the list of search results.
Actually the link in Lykurg's post does not return this thread to me It does return a lot of results telling how to convert an int to a C string, though.
Unless I am misunderstanding what you want, I would suggest you look at QString::number.
Bookmarks