

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a customized atoi() function in C language?
The atoi() is predefined function used to convert a numeric string to its integer value.
Create a customized atoi()
The atoi() only converts a numeric string to integer value, so we need to check the validity of the string.
If this function encounters any non-numeric character in the given string, the conversion from string to integer will be stopped.
Example
#include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ int value; char string1[] = "3567"; value = atoi(string1); printf("String value = %s\n", string1); printf("Integer value = %d\n", value); char string2[] = "TutorialsPoint"; value = atoi(string2); printf("String value = %s\n", string2); printf("Integer value = %d\n", value); return (0); }
Output
String value = 3567 Integer value = 3567 String value = TutorialsPoint Integer value = 0
- Related Questions & Answers
- String to Integer (atoi) in C++
- Create a DataFrame with customized index parameters in Pandas
- Write your own atoi() in C++
- Recursive Implementation of atoi() in C++
- How to create a pointer for strings using C language?
- isalnum() function in C Language
- isupper() function in C Language
- What is a malloc function in C language?
- Enum with Customized Value in C#
- How to use Pre-defined mathematical function in C language?
- Explain Squeeze Function C language
- fgetc() function in C Programming Language
- Explain feof() function in C language with a program
- How to pass entire array as an argument to a function in C language?
- Program with calling function in c language
Advertisements