Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- #include <string.h>
- #include <ctype.h>
- int main(void)
- {
- string name;
- name = get_string("");
- //check first letter only
- //convert to uppercase as well
- if (isalpha(name[0]) != 0)
- {
- printf("%c", toupper(name[0]));
- }
- //find letters after a space
- //If I have a space,
- //then check if next char is a letter
- //If it is, print uppercase version of next letter
- for (int i=0; i<strlen(name); i++)
- {
- if (name[i] == ' ')
- {
- if (isalpha(name[i+1]) != 0)
- {
- printf("%c", toupper(name[i+1]));
- }
- }
- }
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement