C examples for Pointer:Pointer Variable
For character input, report whether it is a letter, and its numerical location in the alphabet.
#include <stdio.h> #include <ctype.h> int letter_location(char ch); int main(void) { char ch;//from ww w .ja v a 2 s . com int location; while ((ch = getchar()) != EOF){ if ((location = letter_location(ch)) == -1) printf("%c is not a letter\n", ch); else printf("%c is a letter: location = %d\n", ch, location); } return 0; } int letter_location(char ch){ if (isalpha(ch)){ ch = tolower(ch); return (ch - 'a' + 1); } else return -1; }