MC logo
Convert To Upper Case
[^] CSc 220 Home
[Introduction] [Boolean and Control] [Functions] [Arrays and Pointers] [Dynamic Arrays] [Array Errors] [Command Array] [Standard Containers] [Structs and Classes] [Automatic Pointer] [Multi-File Programs] [Copying Objects] [Templates] [Inheritance] [Plain C I/O] [Type Odds And Ends] [Plain C Strings] [File I/O]
[Hello, World! (Plain C)] [Average C I/O] [Printf Demo] [Problems With C I/O] [Looping On Read] [Convert To Upper Case] [Indent and Blank Remover] [Reading Lines] [Safer Line Reading] [Printing C++ Strings]
 * Convert the input file to all upper case.
#include <stdio.h>
#include <ctype.h>
int main() 
        int inch;               /* Input character. */

        while((inch = getchar()) != EOF) {

It is a common pattern is to copy input to output one character at a time, performing some sort of processing. This is a simple example which converts all characters to upper case.

The getchar() function returns the next character. Its return type is int, however. This is done so it can return special codes, notably EOF, which are not legal character codes.