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...

Write code for atoi(x) where x is hexadecimal string.

Answer Posted / vadivel t

Hi,
Refer below link to know how atoi() lib fuction works.
http://www.cppreference.com/wiki/c/string/atoi

And find the equalent code which i have written here.

#include<stdio.h>
#include<conio.h>

int MyAtoi(char *cptr);

main()
{
/*Give different inputs like "12.3432", "a4523"," 123"
"abcd", "1234f" and find the qualent output*/

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 ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are enums in c?

1116


What does the error message "DGROUP exceeds 64K" mean?

1168


What are actual arguments?

1045


What is #define size in c?

1118


Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

1035


Which is an example of a structural homology?

1246


Is main a keyword in c?

1083


Explain what is the difference between far and near ?

1048


What math functions are available for integers? For floating point?

1077


What is ambagious result in C? explain with an example.

2551


How can you call a function, given its name as a string?

1099


The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none

1184


What do mean by network ?

1102


Why & is used in c?

1117


Can you please explain the scope of static variables?

998