/* * File: lastchar.c * ---------------- * This program finds the last character in a name. * - modified by Jeff Tian on March 17, 1999 to illustrate the * computation with characters */ #include main() { char c, pre_c; printf("This program displays the last character in a name.\n"); printf("Enter a name (end with space or CR): "); c = getchar(); while (c != ' ' && c != '\n') { pre_c = c; c = getchar(); } printf("The last character is '%c'\n", pre_c); }