Convert Octal String to Integer using stoi() Function in C++ STL Last Updated : 02 Jul, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The octal numeral system, or oct for short, is the base-8 number system and uses the digits 0 to 7, that is to say, 10 octal represents eight, and 100 octal represents sixty-four.How to Convert Octal String To Integer in C++?We can use an in-built library function stoi() which stands for String to Integer. This is a Standard Library Function. stoi() function is used to convert a given string of any format is it binary, or octal that string can be converted to an integer.Syntax:int num = stoi(string_variable_name, [size_t* i] , int base); Parameters:string_variable_name: It is the input string.size t* i: It is an optional parameter (pointer to the object whose value is set by the function), its default value is 0, or we can assign it to nullptr.int base: specifies the radix to determine the value type of the input string. Its default value is 10, it is also an optional parameter. For Octal its value is 8.Return Value: This STL function returns an integer value.Example 1: C++ // C++ program to convert octal string to integer #include <iostream> #include <string> using namespace std; int main() { string oct_str = "124570"; int number = 0; number = stoi(oct_str, 0, 8); cout << "Octal string: " << oct_str << endl; cout << "number: " << number << endl; return 0; } OutputOctal string: 124570 number: 43384 Example 2: C++ // C++ program to convert octal string to integer #include <iostream> #include <string> using namespace std; int main() { string octal_str = "54647"; int number = 0; number = stoi(octal_str, 0, 8); cout << "Octal string: " << octal_str << endl; cout << "number: " << number << endl; return 0; } OutputOctal string: 54647number: 22871 Comment More infoAdvertise with us Next Article Convert Octal String to Integer using stoi() Function in C++ STL S soumyadeeppaul022 Follow Improve Article Tags : Technical Scripter C++ Programs C++ Technical Scripter 2022 STL +1 More Practice Tags : CPPSTL Similar Reads Convert string to integer without using any in-built functions Given a string str, the task is to convert the given string into the number without using any inbuilt function. Examples: Input: str = "985632" Output: 985632 Explanation: Given input is in string form and returned output is in integer form. Input: str = "123" Output: 123 Explanation: Given input is 10 min read Different Ways to Convert Hex String to Integer in C++ STL A hexadecimal number is a number whose base is 16. has numerals 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, and 15. And 10, 11, 12, 13, 14, and 15 these numbers are denoted by A, B, C, D, E, F. In C++ STL there are certain properties that help to convert a hexadecimal string or number to a dec 5 min read How to Convert wstring to int in C++? In C++, std::wstring is a type of string where each character is of a wide character type. These types of strings can be used to store the numerical strings which can then be converted to their corresponding type. In this article, we will see how to convert a wstring to an int in C++. Input: wstr = 2 min read Convert String to Integer Vector in C++ Strings are sometimes used to represent the numerical data which needs to be converted back to integer, but sometimes we may need to convert it to vector of integers instead due to some problems such as too large integer. In this article, we will learn different way to convert a string to integer ve 2 min read Convert Float to String In C++ In this article, we learn how we can convert float to string in C++ using different methods: Using the to_string()Using stringstreamUsing MacrosUsing lexical_cast from the boost library1. Using to_string() The to_string() method takes a single integer variable or other data type and converts it into 3 min read Like