#include <stdio.h>
char DNA[] = "ATCATCTC";
char *tptr;
int tcnt;
int len;
int process() {
int found = 0;
if (tptr == NULL) return 0;
while (*tptr) {
printf("*tptr first time come is: %c with ASCII %d\n", *tptr, *tptr);
len++;
if (*tptr == 'T') {
printf("if, *tptr == 'T', *tptr is: %c with ASCII %d\n", *tptr, *tptr);
tcnt++;
found = 1;
} else {
printf("else, Before *tptr = 'a' + (*tptr - 'A'), *tptr is: %c with ASCII %d\n", *tptr, *tptr);
*tptr = 'a' + (*tptr - 'A');
printf("else, After *tptr = 'a' + (*tptr - 'A'), *tptr now is: %c with ASCII %d\n", *tptr, *tptr);
}
tptr++;
printf("!! after tptr++, it is %s %c \n", tptr, *tptr);
if (found) {
printf(found ? "found is true\n" : "found is false\n");
return 1;}
}
return 0;
}
int idx() {
printf ("for idx(): DNA=%s tptr=%s tptr - DNA = %d\n", DNA, tptr, tptr-DNA);
return (tptr) ? (tptr-DNA) : -1;
}
int main(int argc, char **argv) {
tptr = DNA;
tcnt = 0;
len = 0;
while (process()) printf("%d\n\n", idx());
printf("DNA:%s Tptr:%s\n tcnt:%d len:%d\n", DNA, tptr, tcnt, len);
return 0;
}