atoi
#include <stdlib.h> //atoi's library
#include <stdio.h>
int main (void)
{
string input = "9";
int output = atoi(input);
printf("%i", output);
//this will print out 9 as an int not a string
}
atoi
#include <stdlib.h> //atoi's library
#include <stdio.h>
int main (void)
{
string input = "9";
int output = atoi(input);
printf("%i", output);
//this will print out 9 as an int not a string
}
atoi c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//CONVERT STRING TO INT
int main () {
int val;
char str[20];
strcpy(str, "98993489");
val = atoi(str);
printf("String value = %s, Int value = %d\n", str, val);
strcpy(str, "tutorialspoint.com");
val = atoi(str);
printf("String value = %s, Int value = %d\n", str, val);
return(0);
}
what is atoi in strinf
The C library function int atoi(const char *str) converts the
string argument str to an integer (type int).
Note: It is used in case of string because in strings a number is
also stored as char and we have to do Typecasting form (string -> int)
atoi
int atoi (const char* str);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us