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
Is struct oop?
What are the characteristics of arrays in c?
What is the explanation for the dangling pointer in c?
What is the use of getch ()?
What is c++ used for today?
Write a progarm to find the length of string using switch case?
What is Dynamic memory allocation in C? Name the dynamic allocation functions.
What is the 'named constructor idiom'?
what are the different storage classes in c?
Explain how can I manipulate strings of multibyte characters?
What are header files? What are their uses?
what is the syallabus of computer science students in group- 1?
How will you print TATA alone from TATA POWER using string copy and concate commands in C?
Write a program in c to replace any vowel in a string with z?
How can I automatically locate a programs configuration files in the same directory as the executable?