|
| |||||||||
| Tags: atoi, cpp, functions, header files, library |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| 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. |
|
#2
| ||||
| ||||
| 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. |
|
#3
| ||||
| ||||
| 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;
} Code: Enter a number: 73 The value entered is 73. The double is 146.
__________________ The FIFA Manager 2009 PC Game |
|
#4
| ||||
| ||||
| 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.
__________________ Grand Theft Auto 4 PC Video Game |
|
#5
| ||||
| ||||
| 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. |
|
#6
| ||||
| ||||
| 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;
} Code: The string 123456 as an integer is = 123456
The string 314hello as an integer is = 314 |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 | 09-04-2009 12:07 AM |