Skip to content

Instantly share code, notes, and snippets.

@rberaldo
Last active April 25, 2016 15:46
Show Gist options
  • Save rberaldo/dc25245184d84fccc53535572fc13159 to your computer and use it in GitHub Desktop.
Save rberaldo/dc25245184d84fccc53535572fc13159 to your computer and use it in GitHub Desktop.
// Outputs the uppercase initials of a name
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#define FIRSTLETTER 0
int main(void)
{
// Get user input
string name = GetString();
// Print first letter of the name, then every letter preceded by a blank
// character
int length_name = strlen(name)
printf("%c", toupper(name[FIRSTLETTER]));
for (int i = 0; i < length_name; i++)
if (isblank(name[i]))
printf("%c", toupper(name[i + 1]));
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment