I got is c++ code below.
#include <iostream>
using namespace std;
int main()
{
char ch;
int ct1, ct2;
ct1 = ct2 = 0;
while ((ch = cin.get()) != '$')
{
cout << ch;
ct1++;
if (ch = '$')
ct2++;
cout << ch;
}
cout << "ct1 = " << ct1 << ", ct2 = " << ct2 << "\n";
system("pause");
return 0;
}
Now you can tell what gonna happen if input.
hi$<ENTER>
and the the output should be this right.
hi ct1 = 2, ct2 = 0
But the real output is this.
h$i$ct1 = 2, ct2 = 2.
why is it outputting that i don't understand and how should i fix it.
and i'm using Visual Studio Express 2013 preview for windows desktop.