Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Function 3 - Convert a char digit-string to the int it represents (in the given base) int strtonum(int base, char *bufsrc, unsigned int *ndst) {

Function 3 - Convert a char digit-string to the int it represents (in the given base) int strtonum(int base, char *bufsrc, unsigned int *ndst) { } - The first input parameter is an int specifying the conversion base which is required to be between 2 and 16 (inclusive) - The second input parameter is a pointer to a character string, which is required to be null-terminated string - The third input parameter is a pointer to an unsigned int (for storing the converted integer) - Return value: If all inputs are valid and the conversion can be done successfully, then return 0. Otherwise return a negative integer whose value is informative. Example: If the character string pointed to by bufsrc contains an invalid char (i.e. any char other than the digit characters in the given base) then return -1, else if the string is a valid digit string in the given base but the integer it represents is too large to be stored as an unsigned int then return -2 (overflow check), etc. - As usual, the caller is responsible for valid storage at the locations pointed to by all the pointer parameters that are passed

--------------------------------------------------------------------------------------------------------------------------------------------------

Function 4 - Convert an int to its char-digit-string representation (in the given base) int numtostr(int base, unsigned int *nsrc, char *bufdst) { } - The first input parameter is an int specifying the conversion base which is required to be between 2 and 16 (inclusive) - The second input parameter is a pointer to the unsigned int (required to be non-negative) that needs to be converted to its representation as a string of digit characters in the given base - The third parameter is a pointer to (the start of) a buffer of chars; the caller is required to have allocated sufficient storage to this buffer for holding the converted character digit string including the terminating null character - Return value: On success, return the length of the computed digit string (without leading zero), and return -1 on any error

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions