You can use sprintf to do it, or maybe snprintf if you have it:

char str[ENOUGH];
sprintf(str, "%d", 42);

Where the number of characters (plus terminating char) in the str can be calculated using:

(int)((ceil(log10(num))+1)*sizeof(char))
Answer from cnicutar on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › c language › how-to-convert-an-integer-to-a-string-in-c
How to Convert an Integer to a String in C? - GeeksforGeeks
July 23, 2025 - Input: -567 Output: "-567" Explanation: The integer -567 is converted to the string "-567". There are various methods that can be used to convert integer to a string in C:
Discussions

How to convert integer to string in C? - Stack Overflow
I’m Jody, the Chief Product and Technology Officer at Stack Overflow. Let’s... ... A Holiday to Remember... #11: Great party, dudes! Convert OpenAPI Response Schema to PySpark DataFrame Schema More on stackoverflow.com
🌐 stackoverflow.com
is there any function in c to convert an integer to a string?
atoi() converts string to int, itoa() converts int to string. Still have no clue what 'a' is More on reddit.com
🌐 r/learnprogramming
38
19
December 30, 2022
What’s the best way to convert int to string C when writing struct data to a file? - TestMu AI Community
I’m working with structs in C and want to save their data as strings in a file. For that, I need to convert some integer values into strings. What’s the standard or safest way to perform int to string C conversion? Should I use sprintf, snprintf, or itoa? More on community.testmuai.com
🌐 community.testmuai.com
0
July 7, 2025
Simplest way to convert characters into a string? (C)
There are some details about strings and character arrays in C that trip up new programmers. CS50 attempts to 'paper over' some of these with the 'string' data type. In a few weeks the lectures will reveal the inner workings of 'string' and show you how to work without it. If you change to char key[6] = "abcde"; that will declare and fill in a character array. Then you could, inside your loop, replace individual characters with their uppercase twins: key[i] = toupper(key[i]); and then use printf to print the entire string: printf("%s", key); If that doesn't make sense, it will soon once they strip away 'string' and show you how character arrays and strings 'really' work. More on reddit.com
🌐 r/cs50
5
1
May 2, 2020
🌐
Sanfoundry
sanfoundry.com › c-program-integer-to-string-vice-versa
C Program to Convert Integer to String and Vice-versa - Sanfoundry
May 13, 2022 - Using tostring() function convert an integer to string. Assign the value of ‘num’ variable to ‘n’ variable. While loop is used to check the value of ‘n’ variable is not equal to 0. If the condition is true then execute the loop.
🌐
Quora
quora.com › What-is-the-process-for-converting-an-int-to-a-string-in-the-C-programming-language-Is-there-a-built-in-function-available-for-this-purpose
What is the process for converting an int to a string in the C programming language? Is there a built-in function available for this purpose? - Quora
Answer (1 of 6): Indeed, as other answers have shown, there are built-in functions for this (such as sprintf). However, writing your own function to do this is quite easy. I wrote the below function a while back: [code]template void to_string(T val, char *buffer) { if (!va...
🌐
Delft Stack
delftstack.com › home › howto › how to convert an integer to a string in c
How to Convert an Integer to a String in C | Delft Stack
February 12, 2024 - This tutorial introduces different methods in C to convert an integer into a string. It describes the use of the sprintf(), snprintf(), and itoa() functions in C.
Find elsewhere
🌐
Quora
quora.com › How-do-I-convert-int-to-string-C
How to convert int to string C - Quora
File input/output Types and objects ... bufsz, const char * restrict format, ... ) ; (8) (since C11) Loads the data from the given locations, converts them to character string equivalents and writes the results to a variety of sinks/streams: 1) Writes the results to the output stream ...
🌐
TestMu AI Community
community.testmuai.com › ask a question
What’s the best way to convert int to string C when writing struct data to a file? - TestMu AI Community
July 7, 2025 - I’m working with structs in C and want to save their data as strings in a file. For that, I need to convert some integer values into strings. What’s the standard or safest way to perform int to string C conversion? Should I use sprintf, snprintf, or itoa?
🌐
TutorialsPoint
tutorialspoint.com › c-program-to-convert-a-number-to-a-string
C Program to convert a number to a string
July 30, 2019 - #include<stdio.h> main() { char str[20]; //create an empty string to store number float number; printf("Enter a number: "); scanf("%f", &number); sprintf(str, "%f", number); //make the number into string using sprintf function printf(" You have entered: %s", str); }
🌐
Reddit
reddit.com › r/cs50 › simplest way to convert characters into a string? (c)
r/cs50 on Reddit: Simplest way to convert characters into a string? (C)
May 2, 2020 -

Hello everyone!

In this simple example, how can I replace the new_key string contents with the uppercase of the key string? I can print it alright with the below code, but can't find a way to store the characters in the empty string - there are always either segmentation fault errors or initializer ones.

What would be the best way to make new_key[i] be the content of toupper(key[i])?

#include <stdio.h>

#include <cs50.h>

#include <string.h>

#include <stdlib.h>

#include <ctype.h>

int main(void)

{

string key = "abcde";

string new_key[] = "";

for (int i = 0, len = strlen(key); i < len; i++)

{

char c = key[i];

printf("%c", toupper(c));

}

}

🌐
Aticleworld
aticleworld.com › home › how to convert an int to string in c?
How to convert an int to string in C? - Aticleworld
October 23, 2022 - This blog post will teach efficient ways to convert an int to a string in C using the sprintf, and snprintf. also using the itoa() function.
🌐
WsCube Tech
wscubetech.com › resources › c-programming › programs › int-to-string
How to Convert Int to String in C? 3 Ways With Code
October 23, 2025 - Learn three simple ways to convert an int to a string in C using sprintf(), itoa(), and other methods. Includes code examples!
🌐
GeeksforGeeks
geeksforgeeks.org › c language › what-is-the-best-way-in-c-to-convert-a-number-to-a-string
What is the best way in C to convert a number to a string? - GeeksforGeeks
June 2, 2017 - #include<stdio.h> int main() { char result[50]; float num = 23.34; sprintf(result, "%f", num); printf("\n The string for the num is %s", result); getchar(); } You can also write your own function using ASCII values of numbers.
🌐
Educative
educative.io › answers › how-to-convert-an-int-to-a-string-in-cpp
How to convert an int to a string in C++
The to_string() method accepts a value of any basic data type and converts it into a string. Take a look at the example below: ... boost::lexical_cast provides a cast operator which converts a numeric value to a string value.
🌐
Tomeko
tomeko.net › online_tools › cpp_text_escape.php
Text -> C/C++ string converter
Converting text into C-like literal, escaping newlines, tab, double quotes, backslash.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.convert.tostring
Convert.ToString Method (System) | Microsoft Learn
The following example defines a custom NumberFormatInfo class that defines its negative sign as the string "~" and its positive sign as the string "!". It then calls the ToString(Int32, IFormatProvider) method to convert each element in an array of integers to its equivalent string representation.