I was writing a small piece of code wherein I had to increment value of a variable 'j' if the condition matched.
for(int i=0;i<input.length();i++){//input and base are of type string
for(int j=0;j<base.length();j++){
if(input[i]==base[j])input[i]=base[j+1];
}
}
cout<<input;
When I executed the code, for every input I got a blank string as an output. But if I used ++j instead of j+1, the code seems to work fine. What am I missing here ? Also, the code for j-1 as well as --j works fine. The only problem I face is with j+1. Is it something related to precedence of operators ?