Here is a sample program I wrote giving me the same problem.
I am trying to find where 'A', 'B', and 'C' are.
#include <iostream>
#include <sstream>
#include <string>
char a;
char b[256];
string str2 = "A";
string fileline1 = "ABC"
int i;
int x;
stringstream aa;
int main(){
while ( i < 7 ){
std::size_t found = fileline1.find(str2);
if (found!=std::string::npos){
cout << "first '" << str2 << "' found at: " << found << '\n';
strcpy(b, str2.c_str());
for ( int x=0; b[x] != '\0'; ++x ){
b[x]++;
}}
aa << b;
aa >> str2;
i++;
}
}
The output is:
first 'A' found at: 0
first 'B' found at: 1
first 'B' found at: 1
...
The program never advances to C.