diff options
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; } |