C examples for String:char array
Read user input, alters input, preserving non-letters
#include <stdio.h> #include <ctype.h> // for isalpha() int main(void){ char ch;/*w w w. j av a 2s. c o m*/ while ((ch = getchar()) != '\n'){ if (isalpha(ch)) // if a letter, putchar(ch + 1); // display next letter else // otherwise, putchar(ch); // display as is } putchar(ch); // display the newline return 0; }