// This program demonstrates the use of the different character functions // that are available for you to use when you manipulate characters // We will demo: getchar(), putchar(), islower(), toupper() and the use of EOF // Sasha Vassar Week 5 Lecture 9 #include //This is the library that contains a lot of the character functions #include int main (void) { //Declare a variable int called character char character; printf("Enter your name as an example of getchar() and press Enter: "); //Use the getchar() function to read one character at a time //Remember that this function will take char when a new line is entered character = getchar(); //Keep taking in stuff, until EOF is read //When you press Ctrl+D to signal EOF (end of file) - the while loop will //be exited while (character != EOF) { printf("You entered the character: "); //Using the function putchar to show output one character at a time putchar(character); printf("\n"); //Check if the character is a lower case letter by using the function //islower() found in standard library if (islower(character)) { //If it is, then convert it to upper case letter by using the //function toupper() found in standard library character = toupper(character); printf("Your new character is: "); putchar(character); printf("\n"); } //Get the next character from the buffer character = getchar(); } return 0; }