954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Converting Int to Const Char

How do i convert an int to a const char?
also, how do i convert a string to a const char?

thanks for all the help.

bballmitch
Newbie Poster
10 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

int to const char....
int a=12345;
const char c = a &0xff;

string to const char....
string s("some bollux");
const char c = s[0];

I suspect you meant const char* as the above examples although correct will probably be not what you intended.

string to const char* ....

string s("some bollux");
// then when you need the const char* from this you call strings member func c_str().
if (strcmp(s.c_str(),"some bollux")== 0)
{}

int to const char* ....

int a = 12345;
ostringstream os;
os<

Stoned_coder
Junior Poster
164 posts since Jul 2005
Reputation Points: 19
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You