Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Why do we use header files in c?

1019


What is function prototype?

1057


What is c variable?

998


Can you explain what keyboard debouncing is, and where and why we us it? please give some examples

2145


Write a program to print factorial of given number using recursion?

960


What are the ways to a null pointer can use in c programming language?

1076


What does s c mean on snapchat?

1039


Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?

1076


What is the benefit of using #define to declare a constant?

1044


What is integer constants?

1015


What are register variables in c?

975


What is the difference between int main and void main?

999


What is the difference between ā€˜g’ and ā€œgā€ in C?

3911


How many levels of pointers have?

988


How is = symbol different from == symbol in c programming?

984