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 is a good data structure to use for storing lines of text?

1139


how to print the character with maximum occurence and print that number of occurence too in a string given ?

2533


What are the header files used in c language?

1098


How do you determine the length of a string value that was stored in a variable?

1170


What is volatile variable in c?

1155


How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

1158


what is a function method?give example?

2418


Why c is procedure oriented?

1123


What is a MAC Address?

1123


What does c value mean?

1261


How can I access an I o board directly?

1129


what do u mean by Direct access files? then can u explain about Direct Access Files?

2146


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

1424


What is the purpose of main( ) in c language?

1186


What is graph in c?

1104