Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!