Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 1.) For Fig. 10 on page 317 in the textbook, the function convertToUppercase(char *sPt) was using the library function in ctyreh. As discussed in
Problem 1.) For Fig. 10 on page 317 in the textbook, the function convertToUppercase(char *sPt) was using the library function in ctyreh. As discussed in class, please rewrite this function by yourself. Hint: please use ASCII code and by now rather than using "swith statement in C. you may use character array as lookup table. ! // Fig. 7.10: fig07_10.C 2 // Converting a string to uppercase using a 3 // non-constant pointer to non-constant data. 4 #include 5 #include 6 7 void convertToUppercase(char *sptr); // prototype 8 9 int main(void) 10 { II char string[] - "characters and $32.98"; // initialize char array 12 13 printf("The string before conversion is: %s", string): 14 convert Touppercase(string); 15 printf(" The string after conversion is: %s ", string): 16 } 17 18 // convert string to uppercase letters 19 void convertTouppercase(char *sptr) 20 { 21 while (sptr !- '\0') { // current character is not '0' 22 *SPtr - toupper(sptr); // convert to uppercase 23 ++Ptr; // make sPtr point to the next character 24 } 25} The string before conversion is: Characters and $32.98 The string after conversion is: CHARACTERS AND $32.98 Fig. 7.10 Converting a string to uppercase using a non-constant pointer to non-constant data
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started