need to find number of repeating char

why am i getting zero?

1
2
3
4
5
6
7
    int count=0;
    string numCG ="cg";
    for (string::iterator it = dna[0].begin(), endOfString = dna[0].end(); it != endOfString; it++)
    if ( *it == 'cg')
      count++;
      
      return count;
Since when is "cg" a single character? Do you not get a compilation warning?

no just get 0, how can get it to work with two character like cg
From your silly code it is not clear what dna and endOfString are and how they are related with numCG.
Topic archived. No new replies allowed.