Help me in solving BINSTRING problem

My issue

My code 2:

using namespace std;

int main() 
    int GTX; std::cin >> GTX;
        int n, c=0; cin>>n;
        string s; cin>>s;
        for(int i=1; i<n; i++)
	return 0;

My code 2:

int main() {
    int t;
    cin >> t;
        int n, s, count=0;
        cin >> n >> s;
        string num = to_string(s);
        for (int i=0; i<n-1; i++){
            if (num[i] == num[i+1])
        cout << n - count << endl;
    return 0;

I don’t know how, but the 2nd Code fails gives wrong answer on submission while the first one gives correct answer on submission, where am i wrong in 2nd code?
Please Help me!

Problem Link: BINSTRING Problem - CodeChef

u can’t take input as int then convert it into string like if n is 10^5 then the string of size 10^5 can’t be stored in int or even long long int

1 Like

Ohh! Sorry i forgot about that. Thanks for helping.