Mercurial > baum
changeset 6:ab87b154a96b
first tries for the read input function
author | meillo@marmaro.de |
---|---|
date | Fri, 08 Feb 2008 21:44:07 +0100 |
parents | c202ccccedb5 |
children | 6a6152cf63f7 |
files | baum.c |
diffstat | 1 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/baum.c Fri Feb 08 20:45:17 2008 +0100 +++ b/baum.c Fri Feb 08 21:44:07 2008 +0100 @@ -180,9 +180,41 @@ } +/* read input */ +void read_input(char* filename) { + FILE* fp; + char c; + char* line; + int indent; + char* name; + int value; + + fp = fopen(filename, "r"); + indent = 0; + + while ((c = getc(fp)) != EOF) { + if (c == ' ' || c == '\t') { + indent++; + } else if (c == '(') { + fscanf(fp, "%d", &value); + } else if (c == '\n') { + + if (strcmp(name, "") != 0) { + printf("\nindent: %d\nname: %s\nvalue: %d\n", indent, name, value); + } + indent = 0; + strcpy(name, ""); + value = 0; + } else { + fscanf(fp, "%[a-z]", name); + } + } +} + /* main */ int main(int argc, char* argv[]) { unsigned char shell_return; + /* init(); printTree(root); @@ -194,6 +226,8 @@ printTree(root); delete(root); + */ + read_input("./input_addition"); exit(shell_return); }