// I know of three methods to do this.
//method 1: '#' is the preprocessor operator that converts to string.
//It is called stringification or stringizing operator.
#define TO_STR(x) #x
char *s=TO_STR(123;
//method 2: sprintf()
char*s;
sprintf(s,"%d",123);
//method 3: itoa(), the third parameter is base, so to convert number to binary, put base as 2.
char*s;
itoa(123,s,10)
int numToConvert = *your number*;
// calculate the length of the resulting string
int ENOUGH = malloc(sizeof(char)*(int)log10(numToConvert));
char str[ENOUGH];
sprintf(str, "%d", 42);
// str contains the number in string form
int num = 321;
char snum[5];
// convert num to string and save in string snum
itoa(num, snum, 10);
// print our string
printf("%s
", snum);
char s[] = "42";
int num = atoi(s);
#include <stdio.h>
#include <stdlib.h>
int main()
{
char stringg[35];
int intt = 907;
//in C sprintf() is Function to Convert an Integer to a String.
sprintf(stringg,"%d",intt);
printf("
Your string contains the number: %s
",stringg);
return 0;
}
NSString* myNewString = [NSString stringWithFormat:@"%d", myInt];