nextmatch

Find close matches to a line in a quote file, and print the next one.
git clone git://git.vgx.fr/nextmatch
Log | Files | Refs | Submodules

commit 8ce995f3d8b62ba48ec93fd6ab46402890c86ef8
parent 93227602df347672d117fb395b45c6010595458e
Author: Léo Villeveygoux <leo.villeveygoux@etu.u-bordeaux.fr>
Date:   Fri,  2 Dec 2016 05:08:04 +0100

pass input file as CL argument

Diffstat:
Mnextmatch.c | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/nextmatch.c b/nextmatch.c @@ -21,12 +21,14 @@ int main(int argc, char *argv[]) { size_t len = 0; ssize_t read; - // we could maybe take a file as an argument - fp = stdin; + if(argc >= 3) + fp = fopen(argv[2],"r"); + else + fp = stdin; key = argv[1]; - if (fp == NULL || argc != 2 || key == NULL) + if (fp == NULL || argc < 2 || key == NULL) exit(EXIT_FAILURE); while ((read = getline(&line, &len, fp)) != -1) {