lsflib/src/tokenchar.c
changeset 6 c3dc3eb3b541
child 9 c3fecc82ade6
new file mode 100644
--- /dev/null
+++ b/lsflib/src/tokenchar.c
@@ -0,0 +1,59 @@
+/*
+ *  $Id: tokenchar.c 94 2008-04-05 01:27:30Z mbroeker $
+ * $URL: http://localhost/svn/c/lsflib/trunk/src/tokenchar.c $
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <string.h>
+
+#define MAXCHARS 80
+
+int tokenchar (FILE * f)
+{
+    char line[MAXCHARS];
+    int i;
+    int lines;
+    int chars;
+
+    lines = chars = 0;
+    *line = 0;
+
+    while ((fgets (line, MAXCHARS, f)) != NULL) {
+        for (i = 0; i < strlen (line); i++) {
+            switch (line[i]) {
+            case '.':
+                printf ("%c\n", line[i]);
+                lines++;
+                break;
+
+            case '?':
+                printf ("%c\n", line[i]);
+                lines++;
+                break;
+
+            case '\n':
+                lines++;
+                break;
+
+            case '\t':
+                break;
+
+            default:
+                printf ("UNKNOWN CHAR: %c\n", line[i]);
+                chars++;
+                break;
+            }
+        }
+        *line = 0;
+    }
+
+    rewind (f);
+    return chars;
+}