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

Is struct oop?

979


What are the characteristics of arrays in c?

1002


What is the explanation for the dangling pointer in c?

1079


What is the use of getch ()?

1052


What is c++ used for today?

1077


Write a progarm to find the length of string using switch case?

2041


What is Dynamic memory allocation in C? Name the dynamic allocation functions.

1358


What is the 'named constructor idiom'?

1052


what are the different storage classes in c?

1144


Explain how can I manipulate strings of multibyte characters?

1176


What are header files? What are their uses?

1156


what is the syallabus of computer science students in group- 1?

2284


How will you print TATA alone from TATA POWER using string copy and concate commands in C?

1342


Write a program in c to replace any vowel in a string with z?

1091


How can I automatically locate a programs configuration files in the same directory as the executable?

1125