- 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!
7 Antworten
+ 2
Actually, It will be itoa function!
You guys made this up so complex! 😑
+ 2
Well if you asked precisely maybe you wouldn't get two answers from Python.
+ 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/
+ 1
age = 20
to_string = str(age)
note: input in python is string by default.
0
In c you dont have Strings only arrays of chars