String Comproblem

#include
#include
using namespace std;
int main() {

char str[120];
cin>>str;
int len=strlen(str);
int temp=0;
for(int i=temp;i<len;i++)
{
	int count=1;
	for(int j=i+1;j<len;j++)
	{
		
		if(str[i]==str[j])
		{
			++count;
			++temp;
		}
		++temp;
		if(str[i]!=str[j])
		{
			break;
		}
	}
	cout<<str[i]<<count;
	
}


return 0;

} tell me please the problem in the code.


I have modified your code, instead of if, you are required to use while loop, Try to submit it now