You are here:

C++/Converting int to char*


Hi Eddie,

I am using Visual C++ .NET 2003 and using MFC libraries to develope. My question is extremly easy ! How can I convert a int type to char* by using standard C or even .NET functions it doesn'r matter. Like:

int Num1;
char* StrNum1;

// how can I convert Num1 to char* and put it in StrNum1?



Hello Danesh, thank for for the question.

There is a handy C function for just such a purpose. It can be found in the include file "string.h". It is itoa(), which stands for integer to ascii. Here is an example:

int x = 5;
char *num = itoa(x);

// num now equals 5

For floating point numbers, there is the function ftoa in the same file.

Also, to go from string to int, you can use atoi, and itof, respectively.

If you have any other questions, please don't hesistate to ask.

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 All rights reserved.