2011-11-08 13:21:40 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "dbg.h"
|
|
|
|
|
|
|
|
|
2011-11-11 13:22:26 +00:00
|
|
|
int main(int argc, char *argv[])
|
2011-11-11 00:56:32 +00:00
|
|
|
{
|
|
|
|
int a, b, rc;
|
|
|
|
char c;
|
2011-11-11 13:22:26 +00:00
|
|
|
char filename[1024 * 2];
|
2011-11-11 00:56:32 +00:00
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
printf("Provide filename from which to inputs\n> ");
|
|
|
|
rc = fscanf(stdin, "%s", filename);
|
|
|
|
check(rc == 1, "Failed to read filename");
|
|
|
|
fp = fopen(filename, "r");
|
|
|
|
check(fp != NULL, "Failed to open file %s", filename);
|
|
|
|
|
2011-11-11 13:22:26 +00:00
|
|
|
printf("Reading from file: <a:number> <b:number> <c:letter>\n");
|
2011-11-11 00:56:32 +00:00
|
|
|
rc = fscanf(fp, "%d %d %c", &a, &b, &c);
|
|
|
|
check(rc == 3, "Failed to read from \"%s\".", filename);
|
|
|
|
|
|
|
|
printf("Read in: a=%d b=%d c=%c\n", a, b, c);
|
|
|
|
rc = fclose(fp);
|
|
|
|
check(rc != EOF, "Failed to close file \"%s\"", filename);
|
|
|
|
|
2011-11-08 13:21:40 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
return 1;
|
|
|
|
}
|