diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2013-07-23 16:41:53 -0400 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2013-07-23 16:41:53 -0400 |
commit | e12f7c57ba239f5c3345304e5ad94e2485d321a2 (patch) | |
tree | 8a7523a3e6f97917b41c87398a8508db70f54a30 /count_nucleobases.c | |
parent | a8a252101d371fc3c4da4c8d1b2b2d0e977fc988 (diff) |
open argv[2], use proper indenting, return sucess upon completeiton, use proper printf notation
Diffstat (limited to 'count_nucleobases.c')
-rwxr-xr-x | count_nucleobases.c | 20 |
1 files changed, 13 insertions, 7 deletions
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 <stdlib.h> #include <unistd.h> #include <stdint.h> -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; } |