This function gets a sequence in string and return 1 if all the letters in the string are comprised of capitalized ACGT. At the last place of the string there is ‘\0’. In case there is a char which is not ACGT in the string, the function returns 0. Code: int isLegitSequence(char sequence[]) { int i = 0, j; while(sequence[i] != '\0') { i++; } for (j = (i-1) ; j >= 0 ; j--) { if((sequence[j] != 'A') || (sequence[j] != 'G') || (sequence[j] != 'C') || (sequence[j] != 'T')) { return 0; } } return 1; }
if you mean something like like "does AGCT exist in this string?" then couldn't you just use strstr? Code: int isLegitSequence(char *sequence, char *pattern) { return (strstr(sequence, pattern) != NULL ? 1 : 0); }