The C Program: north.c

  1 #include <stdio.h>
  2 #include <ctype.h>
  3 
  4 #define MAX 1000
  5 char line[MAX];
  6 char south[MAX];
  7 char north[MAX];
  8 
  9 void
 10 parse_input_line () {
 11    int i;
 12    char *s = line;
 13    char *c = south;
 14    for (i=0; i<MAX; i++) south[i]='\0';
 15    while (isalpha(*s)) *c++ = *s++;
 16    while (!isalpha(*s)) s++;             /* skip non-alpha space */
 17    for (i=0; i<MAX; i++) north[i]='\0';
 18    c = north;
 19    while (isalpha(*s)) *c++ = *s++;
 20    printf ("S=%s N=%s\n",south,north);
 21 }
 22 
 23 int
 24 main () {
 25    for (;;) {
 26       fgets (line, MAX, stdin);
 27       if (line[0]=='#') break;
 28       parse_input_line ();
 29    }
 30    for (;;) {
 31       fgets (line, MAX, stdin);
 32       if (line[0]=='#') break;
 33       parse_input_line ();
 34    }
 35 }