Converting string to int in C++
Go to solution
Solved by Mo5,
Use method atoi();
atoi()
Prototype: int atoi(const char *string);
Header File: stdlib.h © or cstdlib (C++)
Explanation: This function accepts a string and converts it into an integer. For example, if "1234" is passed into the function, it will return 1234, an integer. If the string contains a decimal place, the number will be truncated. Eg, "104.21" will be returned as 104.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now