![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert number string to integers in C++
Here we will see how to convert a number string to integer type data. We can solve this problem by using the atoi() function. This function takes string as input and converts into integer data.
The atoi() function is present in the <cstdlib> library.
Input: A number string “1234” Output: 1234
Algorithm
Step 1: Take a number string Step 2: Convert it to integer using atoi() function Step 3: Print the result. Step 4: End
Example Code
#include<iostream> #include<cstdlib> using namespace std; main() { int n; char num_string[20] = "1234"; n = atoi(num_string); cout << n; }
Output
1234
Advertisements