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
Why do we use header files in c?
What is function prototype?
What is c variable?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
Write a program to print factorial of given number using recursion?
What are the ways to a null pointer can use in c programming language?
What does s c mean on snapchat?
Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?
What is the benefit of using #define to declare a constant?
What is integer constants?
What are register variables in c?
What is the difference between int main and void main?
What is the difference between āgā and āgā in C?
How many levels of pointers have?
How is = symbol different from == symbol in c programming?