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 the explanation for cyclic nature of data types in c?

1225


What is n in c?

1072


A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none

1261


Where local variables are stored in c?

1017


What is the difference between abs() and fabs() functions?

1143


How are Structure passing and returning implemented by the complier?

1180


What are derived data types in c?

1098


What is the maximum no. of arguments that can be given in a command line in C.?

1158


Why cant I open a file by its explicit path?

1047


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

3253


How do you declare a variable that will hold string values?

1187


Explain what is the best way to comment out a section of code that contains comments?

1145


What is a protocol in c?

1017


Explain what is #line used for?

1081


Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

2063