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 › convert-string-to-int-in-c
Convert String to int in C - GeeksforGeeks
July 23, 2025 - There are 4 methods to convert a string to int which are as follows: ... The atoi() function in C takes a character array or string literal as an argument and returns corresponding value as integer. It is defined in the <stdlib.h> header file.
🌐
Udemy
blog.udemy.com › home › it & development › software development › c string to int: simple ways to convert to numeric values
C String to Int: Simple Ways to Convert to Numeric Values - Udemy Blog
April 14, 2026 - In this case, the string is an array of characters pointed to by num. Then, we calculate the length of the string using the strlen() function. Next, we loop through the string and convert the string into decimal values.
🌐
Jonathan Cook
cs.nmsu.edu › ~jcook › posts › cpp-string-conversions
C/C++: Converting Strings to Numbers • Jonathan Cook
January 25, 2023 - Notice that there is not a strtoi function – that’s OK, you can use the strtol and then typecast is to an int. int std::stoi( const std::string& str, std::size_t* pos = nullptr, int base = 10 ); long std::stol( const std::string& str, std::size_t* pos = nullptr, int base = 10 ); long long std::stoll( const std::string& str, std::size_t* pos = nullptr, int base = 10 ); unsigned long std::stoul( const std::string& str, std::size_t* pos = nullptr, int base = 10 ); unsigned long long std::stoull( const std::string& str, std::size_t* pos = nullptr, int base = 10 ); float std::stof( const std::string& str, std::size_t* pos = nullptr ); double std::stod( const std::string& str, std::size_t* pos = nullptr ); long double std::stold( const std::string& str, std::size_t* pos = nullptr );
Find elsewhere
🌐
W3Schools
w3schools.com › c › c_type_conversion.php
C Data Type Conversion
C Reference C Keywords C <stdio.h> C <stdlib.h> C <string.h> C <math.h> C <ctype.h> C <time.h> C Examples C Real-Life Examples C Exercises C Quiz C Code Challenges C Practice Problems C Compiler C Syllabus C Study Plan C Interview Q&A · ❮ Previous Next ❯ · Share Link Copied · Sometimes, you have to convert the value of one data type to another type. This is known as type conversion. For example, if you try to divide two integers, 5 by 2, you would expect the result to be 2.5.
🌐
Weber State University
icarus.cs.weber.edu › ~dab › cs1410 › textbook › 8.Strings › c_string_numbers.html
8.2.2.6. C-Strings & Numbers
Advanced C-string to number conversion functions. The functions' increased flexibility requires additional arguments to configure the conversion process. For example, the base argument (called "radix" in some documentation) specifies the base of the digits in the C-string: 10 or decimal, 16 or hexadecimal, 2 or binary, etc.
🌐
Edureka Community
edureka.co › home › community › categories › c++ › easiest way to convert int to string in c
Easiest way to convert int to string in C | Edureka Community
May 31, 2022 - 179739/easiest-way-to-convert-int-to-string-in-c · Home · Community · Categories · C++ Easiest way to convert int to string in C · How to reverse a number in C++? Oct 28, 2024 · undefined reference to `get_string' cs50 library Sep 16, 2023 · fatal error: cs50.h (c language library) : No such file or directory Sep 16, 2023 ·
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › csharp › programming-guide › types › how-to-convert-a-string-to-a-number
How to convert a string to a number - C# | Microsoft Learn
Access to this page requires authorization. You can try changing directories. ... You convert a string to a number by calling the Parse or TryParse method found on numeric types (int, long, double, and so on), or by using methods in the System.Convert class.
🌐
Scaler
scaler.com › home › topics › convert string to int in c++
Convert String to Int in C++ - Scaler Topics
February 5, 2026 - If the starting character is a non-integer value, the stoi() function terminates, giving an error as shown in the output. ... A hands on AI engineering program covering Machine Learning, Generative AI, and LLMs - designed for working professionals & delivered by IIT Roorkee in collaboration ...
🌐
IBM
ibm.com › docs › de › i › 7.4.0
atoi() — Convert Character String to Integer
About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your cookie preferences options.
🌐
WsCube Tech
wscubetech.com › resources › c-programming › programs › int-to-string
How to Convert Int to String in C? 5 Ways With Code
September 17, 2026 - Concatenate Two Strings · How to Reverse a String in C? (6 Programs) C Program to Reverse a Sentence · How to Convert String to Int in C? How to Convert Int to String in C? C Program to Reverse Array · How to Merge Two Arrays in C? Remove Space from String in C ·
🌐
Facebook
facebook.com › groups › cs50 › posts › 1769973409816363
Do anyone know how to convert a int to string on language ...
Find communities for youOver 1 billion people across the globe are using Facebook Groups to explore their favorite topics.
🌐
ByteHide
bytehide.com › blog › turning a string into an int in c#: full guide
Turning a String into an Int in C#: Full Guide - ByteHide
March 27, 2025 - Let’s now dig deeper, delve into this world of string to int conversion. Fasten your seatbelts and read on. In C#, there are a few cool ways you can convert strings into integers. One such method is with the Parse() function.
🌐
W3Schools
w3schools.com › c › c_strings.php
C Strings
Since strings are actually arrays in C, you can access a string by referring to its index number inside square brackets [].
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Template_literals
Template literals (Template strings) - JavaScript | MDN
November 12, 2025 - Dollar signs can be escaped as well to prevent interpolation. ... Any newline characters inserted in the source are part of the template literal. Using normal strings, you would have to use the following syntax in order to get multi-line strings:
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.get_dummies.html
pandas.get_dummies — pandas 3.1.0 documentation
Dummy-coded data. If data contains other columns than the dummy-coded one(s), these will be prepended, unaltered, to the result. ... Convert Series of strings to dummy codes.
🌐
Facebook
facebook.com › groups › cs50 › posts › 941320389348340
How do you convert an int to a string in C??
Find communities for youOver 1 billion people across the globe are using Facebook Groups to explore their favorite topics.