Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* *
- * Exercise 1-12. Write a program that prints its input one word per line.
- * */
- #include <stdio.h>
- #define IS_UPPER(N) ((N) >= 'A' && (N) <= 'Z') /* 'A'==65 && 'Z'==90 */
- #define IS_LOWER(N) ((N) >= 'a' && (N) <= 'z') /* 'a'==97 && 'z'==122 */
- #define IS_ALPHA(N) (IS_LOWER(N) || IS_UPPER(N)) /* [A-Za-z] x*/
- #define OUT 0
- #define IN 1
- int main(void)
- {
- int c = EOF, state = OUT;
- while ((c = getchar()) != EOF) {
- if (IS_ALPHA(c)) {
- state = IN;
- putchar(c);
- }
- else if (state == IN) {
- state = OUT;
- putchar('\n');
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment