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
How are pointers declared in c?
How to create struct variables?
What does == mean in texting?
Is c a great language, or what?
What does typedef struct mean?
What are pragmas and what are they good for?
What is NULL pointer?
Explain zero based addressing.
What is #include stdio h and #include conio h?
What is the data segment that is followed by c?
How is a structure member accessed?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
What does %2f mean in c?
what is the syallabus of computer science students in group- 1?
Was 2000 a leap year?