Skip to content

Commit 21e55e7

Browse files
author
Pankaj Prakash
committed
Added atoi.c
1 parent 5a85b7a commit 21e55e7

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

.gitignore

Whitespace-only changes.

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
# Codeforwin-C-programming
1+
# Codeforwin C programming
22
Codeforwin is a platform for learning, practicing and sharing coding skills.
3+
4+
A blog about computer science, for computer science learner – by computer science lover.

stdlib/atoi.c

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @author Pankaj Prakash
3+
* @website http://codeforwin.org/
4+
* @lastmodified 11:35 AM, January 5, 2018
5+
* @description C programt to convert string to integer using atoi library function.
6+
*
7+
* Syntax - int atoi (const char * str);
8+
* ------------------------------------------------------------------------------------- */
9+
10+
#include <stdio.h>
11+
#include <stdlib.h> // Used for atoi()
12+
13+
#define INTEGER_SIZE 20 // Maximum size of integer in string representation
14+
15+
16+
int main()
17+
{
18+
char number[20];
19+
int num;
20+
21+
22+
/* Input string representation of integer from user. */
23+
printf("Enter any integer: ");
24+
gets(number);
25+
26+
27+
/* Convert string representation of number to integer */
28+
num = atoi(number);
29+
30+
31+
/* Print converted integer */
32+
printf("Converted integer = %d\n", num);
33+
34+
35+
return 0;
36+
}

0 commit comments

Comments
 (0)