-
-
Save sameekapdi/ab2bb0c7b01fb8be3ec25651e1b9d3a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cs50.h> | |
#include <ctype.h> | |
#include <stdio.h> | |
#include <string.h> | |
int main(void) | |
{ | |
string name = get_string(); | |
// Check to ses if string is valid | |
if (name != NULL) | |
{ | |
// Find first character and capitalize | |
int index = 0; | |
while (name[index] == ' ') | |
{ | |
index++; | |
} | |
printf("%c", toupper(name[index])); | |
// Iterate through the rest of the string looking for spaces and printing next Letter | |
for (int i = index + 1, n = strlen(name); i<n; i++) | |
{ | |
if (name[i] == ' ' && name[i+1] != ' ' && name[i+1] != '\0') | |
{ | |
printf("%c", toupper(name[i+1])); | |
} | |
} | |
printf("\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment