Hi all,
I'm taking an intro course to C and am starting to get very lost. We're on the topic of character strings and are being asked to create a program that will capitalize the first letter of every word in the provided prose. I'm successful in getting the entire thing capitalized but can't figure out how to make it so I can access the first characters of each word. Below is the code that capitalizes all the letters. Can someone provide guidance as to how I'd need to make it so it capitalizes only the first letters?
The output should read, To Be Or Not To Be That Is The Question.
Thank you in advance. Below is my code:
Code:#include <stdio.h> #include <ctype.h> #include <string.h> int main(void) { char prose[] = "to be or not to be that is the question"; int i, len; puts (prose); len = strlen(prose); for (i = 0; i < len; i++) { prose[i] = toupper(prose[i]); } puts (prose); return 0; }