xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to convert integer or double types to string types in C
C Online Editor
Execute Code
More C Sample Codes
#include <stdio.h> #include <stdlib.h> //remember to include the library int main() { // Convert integer to string (char array) int integerVariable = 1225; // Integer data char convertedintegertoString[10]; //Char array sprintf(convertedintegertoString, "%d", integerVariable); //converting data printf("%s\n", convertedintegertoString); //output // Convert string (only numbers) to integer const char* stringVariable = "1225"; // pointer to a constant character string (as string data) int convertedStringtoInteger = atoi(stringVariable); //atoi method to convert String to integer printf("%d\n", convertedStringtoInteger); //output // Convert double to string double doubleVariable = 123.45; // double data char convertedDoubletoString[20];//char array sprintf(convertedDoubletoString, "%lf", doubleVariable); //data conversion printf("%s\n", convertedDoubletoString); //output return 0; }