atoi(): This function convert string to an integer. This function Parses the C-string str interpreting its content as an integral number, and returned it as a value of type int. The string may contain some other characters than digits after the digits, these characters are ignored.
Parameters: One parameter is required for this function.
str: A string that is to be converted into the int type.
Syntax:
atoi(str)
For Example:
atoi("12.45") = > It return 12.
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){char str[] = "12.45";cout << atoi(str) << "\n";return 0;}
No comments:
Post a Comment