A DNA sequence is a sequence of some combination of the char
Solution
// C program dnaSearch.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <string.h>
int main(int argc, char const *argv[])
{
FILE *inputFile;
if(argc < 3)
{
printf(\"Input arguments missing\ \");
return 0;
}
if ((inputFile = fopen(argv[1], \"r\")) == NULL)
{
printf(\"Error! opening file\");
// Program exits if file pointer returns NULL.
exit(1);
}
int i,j ;
char str[100], sub[100];
// open file
inputFile = fopen(argv[1],\"r\");
// reads text until newline
fscanf(inputFile,\"%[^\ ]\", str);
strcpy(sub , argv[2]);
int count = 0;
const char *tmp = str;
while(tmp = strstr(tmp, sub))
{
count++;
tmp++;
}
printf(\"%s appears %d times\ \", sub, count);
fclose(inputFile);
return 0;
}
/*
dna01.txt
GGAAGTAGCAGGCCGCATGCTTGGAGGTAAAGTTCATGGTTCCCTGGCCC
output:
GTA appaers 2 times
*/

