create template for c stdin line problems
This commit is contained in:
parent
7298e6d87b
commit
9f21ca51fb
|
|
@ -1,6 +1,8 @@
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-Wall
|
CFLAGS=-Wall
|
||||||
|
|
||||||
|
build: bin/part01 bin/part02
|
||||||
|
|
||||||
run1: bin/part01
|
run1: bin/part01
|
||||||
cat data/p01data.txt | bin/part01
|
cat data/p01data.txt | bin/part01
|
||||||
|
|
||||||
|
|
@ -13,10 +15,10 @@ test1: bin/part01
|
||||||
test2: bin/part02
|
test2: bin/part02
|
||||||
cat data/p02test.txt | bin/part02
|
cat data/p02test.txt | bin/part02
|
||||||
|
|
||||||
bin/part01:
|
bin/part01: clean
|
||||||
$(CC) src/part01.c -o bin/part01
|
$(CC) src/part01.c -o bin/part01
|
||||||
|
|
||||||
bin/part02:
|
bin/part02: clean
|
||||||
$(CC) src/part02.c -o bin/part02
|
$(CC) src/part02.c -o bin/part02
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,25 @@
|
||||||
|
CC=gcc
|
||||||
|
CFLAGS=-Wall
|
||||||
|
|
||||||
|
run1: bin/part01
|
||||||
|
cat data/p01data.txt | bin/part01
|
||||||
|
|
||||||
|
run2: bin/part02
|
||||||
|
cat data/p02data.txt | bin/part02
|
||||||
|
|
||||||
|
test1: bin/part01
|
||||||
|
cat data/p01test.txt | bin/part01
|
||||||
|
|
||||||
|
test2: bin/part02
|
||||||
|
cat data/p02test.txt | bin/part02
|
||||||
|
|
||||||
|
bin/part01:
|
||||||
|
$(CC) src/part01.c -o bin/part01
|
||||||
|
|
||||||
|
bin/part02:
|
||||||
|
$(CC) src/part02.c -o bin/part02
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f bin/*
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define debug_printf(...) do{ fprintf( stderr, __VA_ARGS__ ); } while( 0 )
|
||||||
|
#else
|
||||||
|
#define debug_printf(...) do{ } while ( 0 )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LINE_MAX 90
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]){
|
||||||
|
int linesProcessed = 0;
|
||||||
|
char line[LINE_MAX];
|
||||||
|
|
||||||
|
while (fgets(line, LINE_MAX, stdin) != NULL) {
|
||||||
|
linesProcessed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n Processed %d Lines\n", linesProcessed);
|
||||||
|
printf("===================================\n");
|
||||||
|
printf("Answer: \nXXXX\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define debug_printf(...) do{ fprintf( stderr, __VA_ARGS__ ); } while( 0 )
|
||||||
|
#else
|
||||||
|
#define debug_printf(...) do{ } while ( 0 )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LINE_MAX 90
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]){
|
||||||
|
int linesProcessed = 0;
|
||||||
|
char line[LINE_MAX];
|
||||||
|
|
||||||
|
while (fgets(line, LINE_MAX, stdin) != NULL) {
|
||||||
|
linesProcessed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n Processed %d Lines\n", linesProcessed);
|
||||||
|
printf("===================================\n");
|
||||||
|
printf("Answer: \nXXXX\n");
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue