top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What do the functions atoi(), itoa() and gcvt() do

+6 votes
901 views
What do the functions atoi(), itoa() and gcvt() do
posted Dec 3, 2013 by Prachi Agarwal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+2 votes

atoi()-is used for convert string to integer.
itoa()-is used for convert integer to string.
gcvt()-is used for convert double to string.

answer Dec 3, 2013 by Giri Prasad
0 votes

atoi() is a macro that converts integer to character.
itoa() It converts an integer to string
gcvt() It converts a floating point number to string

answer Dec 4, 2013 by Neeraj Pandey
Similar Questions
+3 votes

In K&R I found a piece of code which showed how atoi() works. It said like s[i] - '0' will give a numeric value of the character.

Can someone please explain it to me. I tried to search around but they only explain it with integers and not with characters. Say you are given s[i] = 'C'.

0 votes
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
  int *p
  int size = 10;

  p=(int*)calloc(size,sizeof(int));

  while(i != size)
  {
    *p++=1;       /*    METHOD 1       */
    i++;
  }

  i=0;

  while(i != size)
  {
    i[p] = 1;         /*    METHOD 2    */
    i++;
  }

}    
...