From: Chris Date: Fri, 6 Feb 2015 23:40:42 +0000 (+0100) Subject: Opdracht afgemaakt X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=10246c0ef62a046e55efe7684133fc158598b78f;p=sws1-1415.git Opdracht afgemaakt --- diff --git a/ass1/chris/sws1-s4109503-s4202015/exercise2/Makefile b/ass1/chris/sws1-s4109503-s4202015/exercise2/Makefile new file mode 100644 index 0000000..4d17b59 --- /dev/null +++ b/ass1/chris/sws1-s4109503-s4202015/exercise2/Makefile @@ -0,0 +1,4 @@ +all: parsegenome.c + gcc -o -Wall -o parsegenome parsegenome.c +clean: + $(RM) parsegenome diff --git a/ass1/chris/sws1-s4109503-s4202015/exercise2/parsegenome b/ass1/chris/sws1-s4109503-s4202015/exercise2/parsegenome new file mode 100755 index 0000000..df21604 Binary files /dev/null and b/ass1/chris/sws1-s4109503-s4202015/exercise2/parsegenome differ diff --git a/ass1/chris/sws1-s4109503-s4202015/exercise2/parsegenome.c b/ass1/chris/sws1-s4109503-s4202015/exercise2/parsegenome.c new file mode 100644 index 0000000..e5c1411 --- /dev/null +++ b/ass1/chris/sws1-s4109503-s4202015/exercise2/parsegenome.c @@ -0,0 +1,53 @@ +#include +#include + +int main(int argc, char *argv[]){ + if(argc != 2){ + printf("Not the right amount of arguments given"); + return -1; + } + FILE *file = fopen(argv[1], "r"); + if(file == 0){ + return -1; + } + int a = 0; + int c = 0; + int g = 0; + int t = 0; + int amount_chars = 0; + char x; + while((x = fgetc (file) ) != EOF){ + switch(x){ + case 'A': + a += 1; + amount_chars += 1; + break; + case 'C': + c += 1; + amount_chars += 1; + break; + case 'G': + g += 1; + amount_chars += 1; + break; + case 'T': + t += 1; + amount_chars += 1; + break; + case '\n': + if(amount_chars % 100 != 0){ + printf("%i", amount_chars); + printf("Not right format"); + return -1; + } + break; + default: + return -1; + } + } + if(amount_chars != 50000){ + return -1; + } + printf("There were %i A's, %i C's, %i G's, %i T's\n",a,c,g,t); + return 0; +}