Starting from:

$25

CS39003-Assignment 2 Creating Library on x86-64 Platform Solved

. Write a C++ program file consisting of the following functions to create a library. You are not allowed to use any standard library function. Also, do not include the function main() in this file.

•    int printStringUpper (char *) – print a string of characters terminated by ‘\0’, where all the alphabetic characters are printed in uppercase. The return value is the number of characters printed (excluding the ‘\’ character).

•    int readHexInteger (int *n) – read a signed hexadecimal integer in ‘%x’ format, convert it to decimal, and pass the value through the pointer parameter. The return value is GOOD (for success) or BAD (on failure).

•    int printHexInteger (int n) – print the (signed) decimal integer n in left-aligned hexadecimal form. A negative number must be preceded by the minus sign; whereas no prefix is required for non-negative numbers. For example, the number -65529 will be printed as –FFF9. On success, the function will return the number of characters printed, and on failure it will return BAD.

•    int readFloat (float *f) – read a floating point number in ‘%f’ format (for example, –123.456), where the value is passed through the pointer parameter. The return value is GOOD or BAD.

•    int printFloat (float f) – print the floating point number f in left-aligned form. Printing sign for a negative number is mandatory while for a positive number it is not required. There must be a mandatory decimal point in the output (for example, 25 will be printed as 25.). On success, the function will return the number of characters printed, and on failure it will return BAD.

Use the following header file for your C++ program.

/* Header file for Assignment 2: Name it as “toylib.h” */

#ifndef  TOYLIB H

#define TOYLIB H

#define BAD -1 #define GOOD 1

int printStringUpper (char *);

1

int printHexInteger (int); int readHexInteger (int *); int readFloat (float *); int printFloat (float);

#endif

More products