![]() |
In C++, a character array is treated as a sequence of characters also known as a string. Converting a character array into an integer is a common task that can be performed using various methods and in this article, we will learn how to convert char array to int in C++. Example Input: Convert Char Array to Int in C++To convert a char array to int in C++, we can use the atoi() function provided by the <cstdlib> header. Following is the syntax to use atoi function: Syntax of atoi()int atoi(const char arr) where:
C++ Program to Convert Char Array to IntThe following program illustrates how we can convert a char array to int in C++ using the atoi function:
Output The integer value is: 12345 Time Complexity: O(N), where N is the length of the character array. |
Reffered: https://www.geeksforgeeks.org
C++ |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 21 |