create template for c stdin line problems

This commit is contained in:
icaema 2023-12-01 18:17:14 -05:00
parent 7298e6d87b
commit 9f21ca51fb
9 changed files with 79 additions and 2 deletions

View File

@ -1,6 +1,8 @@
CC=gcc
CFLAGS=-Wall
build: bin/part01 bin/part02
run1: bin/part01
cat data/p01data.txt | bin/part01
@ -13,10 +15,10 @@ test1: bin/part01
test2: bin/part02
cat data/p02test.txt | bin/part02
bin/part01:
bin/part01: clean
$(CC) src/part01.c -o bin/part01
bin/part02:
bin/part02: clean
$(CC) src/part02.c -o bin/part02
.PHONY: clean

BIN
day-01/bin/part02 Executable file

Binary file not shown.

View File

@ -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/*

View File

View File

View File

View File

View File

@ -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");
}

View File

@ -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");
}