Question: Problem 2 Instead of writing my_printf(), you will write output functions that perform specific, sometimes simplified, basic capabilities of printf(). All functions output is to

Problem 2

Instead of writing my_printf(), you will write output functions that perform specific, sometimes simplified, basic capabilities of printf(). All functions output is to the standard output. All functions return the number of characters printed. Place these in my_string.c. Have your main.c test each of these for several different cases try to break them!

int printC(int c); // Outputs the character c if it is printable int printS(const char *s); // Outputs the string s int printI(int i); // Outputs the integer i as a base-10 string int printX(int i); // Outputs the integer i as a hexadecimal string int printF(double x, int n); // Format: fff.ffff

Outputs x as a fixed point string with n digits to the right of the decimal point. Value should be properly rounded. If n < 0, do not print the decimal point (otherwise the same as n = 0).

int printE(double x, int n); // Format: f.fffea (x = f.fff * 10^a)

Outputs x in exponential notation with exactly one non-zero digit to the left of the decimal point (unless x = 0) and n digits to the right, a lowercase e, and the exponent. If n < 0, do not print the decimal point (otherwise same as n = 0).

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!