atoi

Overview :

The "atoi" is a macro which convert a string to the integer value.

Syntax :
int atoi(cont char *x);
Description :

The "atoi" function accepts 1 parameters

  • char *x -> It is a pointer which points to the string which is to converted into integet.


  • The function returns the converted string which is an integer

  • The function returns 0 if string cannot be converted



Example :
#include<conio.h>
#include <stdlib.h>
#include <stdio.h>

 int main(void)
 {
    int value;
	char *string;
	clrscr();
	printf("\nEnter the string : ");
	scanf("%s",string);

    value = atoi(string);
    printf("\nThe equivalent value is : %d",value);
	getch();
    return 0;
 }

Comments

comments powered by Disqus