Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 27-02-2010
Member
 
Join Date: Jan 2010
Posts: 26
The atoi() function of the C++

Hi, All. I am the student of the IT. I can have the good knowledge of the programming languages not all of the languages but some of them. I can also like to do the programming. But I can not heard about the atoi() function of the C++ language. So, I want to know about the atoi() function of the C++ language. And how can I use this function in the coding of the C++ language. Reply me if you can have the answer for me.
Reply With Quote
  #2  
Old 27-02-2010
Member
 
Join Date: Jan 2008
Posts: 1,515
The atoi() function

The atoi() function can be used in the C++ language to transform the string into an integer. The atoi() function can be the member of the cstdlib header files of the C++ language library. The atoi() function can parses the C++ string by translating its content as an integer number which can be returned as an int value. The following can be the syntax of the atoi() function in the C++ language :
Code:
int atoi ( const char * sr );

Last edited by Modifier : 27-02-2010 at 04:56 PM.
Reply With Quote
  #3  
Old 27-02-2010
Member
 
Join Date: May 2008
Posts: 2,383
The atoi()

This program can states you or guides you how to use and how to implement the atoi() function in the programming of the C++ language as follows :
Code:
#include <stdio.h>
#include <stdlib.h>
int main ()
{
  int j;
  char sInpt [256];
  printf ("Enter a number: ");
  fgets ( sInpt, 256, sdn );
  j = atoi (sInpt);
  printf ("The value entered is %d. The double is %d.\n",j,j*2);
  return 0;
}
Output:
Code:
Enter a number: 73
The value entered is 73. The double is 146.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #4  
Old 27-02-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: The atoi() function of the C++

Hi, according to me the atoi() function can an accepts a string and then can transforms that string into an integer type. For an example : If "5678" can be passed to the atoi() function then the atoi() function can returns the 5678 as an integer. If the string can contains a decimal value then the number that could be truncated. i.e., "401.31" could be returned as 401 and excludes the numbers that can be after the decimal places.
Reply With Quote
  #5  
Old 27-02-2010
Member
 
Join Date: Nov 2005
Posts: 1,323
The atoi() function of the C++

The atoi() function can returns the integer value if there can be success and the atoi() function can returns the zero value if there can be a failure. If the resultant value can be the out of range of the atoi() function then it can returns the maximum or minimum integer value. The following can be the syntax of the atoi() function of the C++ language :
1. str : This parameter can contains the cstring that can be starting with the representation of an integer value or number.
Reply With Quote
  #6  
Old 27-02-2010
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: The atoi() function of the C++

PROGRAM :
Code:
   #include <stdlib.h>
    #include <stdio.h>
    int main(void)
    {
      char *str = "123456";
      int n = atoi(str);
      printf("The string %s as an integer is = %d\n",str,n);
      char *str2 = "314hello";
      n = atoi(str2);
      printf("The string %s as an integer is = %d\n",str2,n);
      return 0;
    }
Output :
Code:
    The string 123456 as an integer is = 123456
    The string 314hello as an integer is = 314
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "The atoi() function of the C++"
Thread Thread Starter Forum Replies Last Post
c++ equivalent function to the c-function 'sprintf Dilbert Software Development 6 13-12-2011 04:03 PM
c# function equivalent to gettime function in javascript Omaar Software Development 4 10-03-2010 10:44 PM
How to pass function with parameters to another function in PHP? Linoo Software Development 5 27-02-2010 07:52 PM
How does abstract function differs from virtual function? Maddox G Software Development 5 29-01-2010 11:32 AM
Function keys don't function under windows XP GunFighter Hardware Peripherals 3 08-04-2009 11:07 PM


All times are GMT +5.5. The time now is 07:13 PM.