SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
Convert string to int without using library function in c
Convert string to int without using library function in c
Input:
Enter the string: 1234
Output:
The string 1234 converted to number 1234
Implementation:
#include
#include
#include
int main(void) { char *s; int n=0,i=0; s=(char*)malloc(sizeof(char)*1000000); printf("Enter the string:\n"); scanf("%s",s); while(*(s+i)) { n=(n*10)+((int)*(s+i)-(int)'0'); i++; } printf("The string %s converted to number %d",s,n); return 0; }
PREVIOUS
NEXT
HOME