All pastes #617340 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-07-13 05:05 UTC
rendered paste body
#include <stdlib.h>
#include <stdio.h>

int
main(void)
{
    int c;
    char string[64];
    unsigned int ii;
    unsigned int pos = 0;
    FILE *conf_file = fopen("test.conf", "rw");

    while ((c = fgetc(conf_file)) != EOF) {
        switch (c) {
        case ' ':
        case '\t':
        case '\r':
        case '\n':
            pos++;
            break;
        case '\"':
            ii = 0;
            while ((c = fgetc(conf_file)) != '\"')
                string[ii++] = c;
            string[ii] = 0;
            printf("string: %s\n", string);
            pos += ii+1;
            break;
        default:
            break;
        }
    }
    return getchar();
}