Lab Exercise: Entering, Compiling and Running C Programs

Source file:  chartest.c
 
/* CSC265W */
/* Randy Pratt 01/27/99 */
/* Gets a character input from user, then displays the character entered */

#include <pima.h>
void main() {
    char c;                                 /* Declare c as data type int */

    puts("Enter a character:");             /* Prompt user for a character */
    c = getchar();                          /* c gets character entered */
    puts("");                               /* blank line */
    putchar(c);                             /* display character-no newline */
    puts(" was the character entered.");    /* display sentence remainder */
}

 
Output of program:
 
A:\>chartest
Enter a character:
M

M was the character entered.

A:\>