39 lines
715 B
C
39 lines
715 B
C
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#define DEFAULT_FILE "input.txt"
|
|
#define STRBUF_LEN 200
|
|
#define ISDIGIT(X) (X >= '0' && X <= '9')
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
// Get filename as an argument, if there is one
|
|
char *path = (argc > 1) ? argv[1] : DEFAULT_FILE;
|
|
|
|
if (!path)
|
|
{
|
|
printf("Requires input file.\n");
|
|
return 1;
|
|
}
|
|
|
|
FILE *file = fopen(path, "r");
|
|
char strbuf[STRBUF_LEN] = {0};
|
|
|
|
if (!file)
|
|
{
|
|
printf("Could not find file.");
|
|
return 1;
|
|
}
|
|
|
|
|
|
while (fgets(strbuf, STRBUF_LEN, file))
|
|
{
|
|
// Code goes here
|
|
|
|
}
|
|
|
|
return 0;
|
|
} |