- 1

How to typecast integer into string in C

I need a function or algorithm which will typecast a integer value into string! Help me!

7th Jan 2020, 3:11 PM
Nihan
Nihan - avatar
7 Antworten
+ 2
Actually, It will be itoa function! You guys made this up so complex! 😑
7th Jan 2020, 4:30 PM
Nihan
Nihan - avatar
+ 3
Nihan decide whether you need help with C (as in question) or Python (as in tag)
7th Jan 2020, 3:53 PM
Jakub Stasiak
Jakub Stasiak - avatar
+ 2
Well if you asked precisely maybe you wouldn't get two answers from Python.
7th Jan 2020, 6:09 PM
Jakub Stasiak
Jakub Stasiak - avatar
+ 2
Nihan Try to run this snippet #include <stdio.h> #include <stdlib.h> int main() { const char* s = "2020"; printf("atoi(%s) returns %d\n", s, atoi(s)); printf("itoa(2020) returns %s\n", itoa(2020)); // undefined symbol: 'itoa' return 0; } If you get a warning or error, see the reference for `itoa` below, and notice particularly the "Portability" section. http://www.cplusplus.com/reference/cstdlib/itoa/
7th Jan 2020, 6:58 PM
Ipang
+ 1
age = 20 to_string = str(age) note: input in python is string by default.
7th Jan 2020, 3:38 PM
RKK
RKK - avatar
0
In c you dont have Strings only arrays of chars
7th Jan 2020, 4:12 PM
Jnn
Jnn - avatar