plz answer.. a program that takes a string e.g. "345" and
returns integer 345
Answer Posted / vadivel t
The equalent code to atoi() library fuction which i hav
written, below.
#include<stdio.h>
#include<conio.h>
int MyAtoi(char *cptr);
main()
{
char *cptr = "123445";
printf("INTEGER EQU IS: %d\n", MyAtoi(cptr));
getch();
}
int MyAtoi(char *cptr)
{
int iptr = 0;
while((*cptr != '\0') && ((*cptr >= 48 && *cptr <= 57) ||
(*cptr == 32)))
{
if(*cptr != ' ')
iptr = (iptr * 10) + (*cptr - 48);
cptr++;
}
return iptr;
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
When can you use a pointer with a function?
What is the difference between struct and union in C?
What is the difference between a string and an array?
Can we replace the struct function in tree syntax with a union?
which is an algorithm for sorting in a growing Lexicographic order
Can 'this' pointer by used in the constructor?
How many levels of indirection in pointers can you have in a single declaration?
to find the closest pair
Why do we use return in c?
What language is windows 1.0 written?
What does c mean in basketball?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
What is quick sort in c?
What is a volatile keyword in c?
What is bin sh c?