/**************************************************************************** * capitalize.c * * Computer Science 50 * David J. Malan * * Capitalizes a given string. * * Demonstrates casting and iteration over strings as arrays of chars. ***************************************************************************/ #include #include #include int main(int argc, char *argv[]) { int i, n; string s; // get line of text s = GetString(); // capitalize text for (i = 0, n = strlen(s); i < n; i++) { if (s[i] >= 'a' && s[i] <= 'z') printf("%c", s[i] - ('a' - 'A')); else printf("%c", s[i]); } printf("\n"); }