#include #include #include #include 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; 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); } unsigned int ch = 0; while ((ch = getc(fh)) != EOF) { switch(ch) { case 'A': case 'a': a++; break; case 'C': case 'c': c++; break; case 'G': case 'g': g++; break; case 'T': case 't': t++; break; } } printf("A:%llu\nC:%llu\nG:%llu\nT:%llu\n", a, c, g, t); return EXIT_SUCCESS; }