c convert int to string code example

Example 1: change int to string cpp

#include <string> 

std::string s = std::to_string(42);

Example 2: c int to string

#include <stdio.h>

int main()
{

  char number_str[10];
  int number = 25;

  sprintf(number_str, "%d", number);
  printf("Converted to string : %s\n", number_str);
  
  return 0;

}

Example 3: change integer to string c++

string str_val = to_string(int_val);

Example 4: convert integer to string c++

std::to_string(23213.123)

Example 5: objective c convert int to string

NSString* myNewString = [NSString stringWithFormat:@"%d", myInt];

Example 6: integer to stringc

int someInt = 368;
char str[12];
sprintf(str, "%d", someInt);