Hey Y'all, I'm having trouble with this homework problem. I got the first part down which is why you see all those p=j and p=1 pointers. But i am stuck on the second part. I'm suppose to:
1. Initialize pc to the beginning of my_cstring.
2. Use it to capitalize the 1st and 5th characters of my_cstring.
3. Use your char pointer to output the integer value of each element of my_cstring (including the 8th element, my_cstring[7]). (hint: you could copy each element to an integer and output it, or use static_cast<int>(...) ).
The problem is I can't seem to get the letters to capitalize. Any help is greatly appreciated!!!
pc = &my_cstring[0];
toupper(*pc);
cout << *pc << endl;
1. Initialize pc to the beginning of my_cstring.
Good, you've done that.
2. Use it to capitalize the 1st and 5th characters of my_cstring.
You've done the first, but you also need to do the 5th.
3. Use your char pointer to output the integer value of each element of my_cstring (including the 8th element, my_cstring[7]). (hint: you could copy each element to an integer and output it, or use static_cast<int>(...) ).
You need a loop to traverse the char array, my_cstring. Visit each element, cast it to an int, and print it.
Okay, I figured out how to capitalize the 1st and 5th elements but now I am stuck on the third part. What do you mean to visit each element and cast it as an int?