From e12f7c57ba239f5c3345304e5ad94e2485d321a2 Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Tue, 23 Jul 2013 16:41:53 -0400 Subject: open argv[2], use proper indenting, return sucess upon completeiton, use proper printf notation --- count_nucleobases.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'count_nucleobases.c') diff --git a/count_nucleobases.c b/count_nucleobases.c index 6edf5e8..d21a2d2 100755 --- a/count_nucleobases.c +++ b/count_nucleobases.c @@ -2,14 +2,18 @@ #include #include #include -main() { +int main(int argc, char **argv) { -long unsigned long a = 0; -long unsigned long c = 0; -long unsigned long g = 0; -long unsigned long t = 0; + long unsigned long a = 0; + long unsigned long c = 0; + long unsigned long g = 0; + long unsigned long t = 0; -FILE *fh = fopen("dna.txt", "r" ); + if(argc != 2) { + printf("Please supply a filename, and only a filename\n"); + exit(EXIT_FAILURE); + } + FILE *fh = fopen(argv[1], "r" ); if(fh == NULL) { fprintf(stderr, "could not open dna.txt\n"); exit(EXIT_FAILURE); @@ -37,5 +41,7 @@ FILE *fh = fopen("dna.txt", "r" ); } } - printf("A:%lu\nC:%lu\nG:%lu\nT:%lu\n", a, c, g, t); + printf("A:%llu\nC:%llu\nG:%llu\nT:%llu\n", a, c, g, t); + + return EXIT_SUCCESS; } -- cgit v1.2.3