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))
More Related Contents:
- How to convert an int to string in C?
- How to convert integer to string in C? [duplicate]
- isnt everything where it should be, why the segmentation fault?
- I had issue in below mention program to assign a value to the pointer.String concatenation Program( *s1=*s2) [closed]
- String compare function in C [closed]
- String manipulation in C (replace & insert characters)
- returning string in C function [closed]
- How do I concatenate two strings in C?
- How does concatenation of two string literals work?
- Catch and compute overflow during multiplication of two large integers
- Check substring exists in a string in C
- How do you convert a byte array to a hexadecimal string in C?
- What do numbers using 0x notation mean?
- SIMD signed with unsigned multiplication for 64-bit * 64-bit to 128-bit
- Looking for a good hash table implementation in C [closed]
- How do you store an arbitrarily large integer value in memory?
- Tokenizing strings in C
- Why doesn’t scanf need an ampersand for strings and also works fine in printf (in C)?
- Why do we define INT_MIN as -INT_MAX – 1? [duplicate]
- string array with garbage character at end
- Modify a string with pointer [duplicate]
- Is there any reason not to use fixed width integer types (e.g. uint8_t)?
- Creating C formatted strings (not printing them)
- What’s the difference between “int” and “int_fast16_t”?
- C split a char array into different variables
- A possible algorithm for determining whether two strings are anagrams of one another? [closed]
- Counting words in a string – c programming
- convert string to integer in c++
- How to convert int to string in C++
- Can I compare int with size_t directly in C?