I want to compare a sub range of a char array to another string using strcmp. I made the dna char array by reading from a textfile and then concatenating them into a longer char array.
char dna[10] = "ATGGATGATGA";
char STOP_CODON[3] = "TAA";
int TS1 = strcmp(&STOP_CODON[0]),dna[0]);
int TS2 = strcmp(&STOP_CODON[1]),dna[1]);
int TS3 = strcmp(&STOP_CODON[2]),dna[2]);
if(T1+T2+T3) == 3 {
int T = 1;
}
So if they all match then T returns as true(1) I want to compare the STOP_CODON with dna in subranges of three chars. I cant figure a way to do this simply. In matlab you can do:
strcmp(STOP_CODON[1:3],dna[1:3])
Is something like this possible in C? I want to use this to eventually iterate over the whole dna array which is actuality is 60,000 chars long
printf("%s.6\n",&dna[1]);
printf has this kind of functionality but I want to so this with strcmp. Is there something more efficient than this in C?