Aisha Rizwan
0
Q:

atoi c

#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
}
5
#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);
}
0

New to Communities?

Join the community