Remove Spaces gfg

Question–>
https://practice.geeksforgeeks.org/problems/remove-spaces/0#
code–>

#include <iostream>
using namespace std;

int main() {
	//code
	int t;
	cin>>t;
	while(t--){
	    cin.ignore();
	    string s;
	    getline(cin,s);
	    string b="";
	   // int j=0;
	    for(int i=0;i<s.length();i++){
	        if( s[i]==' '){
	            continue;
	        }
	        else{
	            b+=s[i];
	        }
	    }
	    cout<<b<<endl;
	}
	return 0;
}

Not passing all testcases help

Hey @sheikhhaji18

#include <iostream>
using namespace std;
int main() {
	//code
	int t;
	cin>>t;
    cin.ignore(); //added
	while(t--){
	   // cin.ignore();//removed
	    string s;
	    getline(cin,s);
	    string b="";
	    for(int i=0;i<s.length();i++){
	        if( s[i]==' '){
	            continue;
	        }
	        else{
	            b+=s[i];
	        }
	    }
	    cout<<b<<endl;
	}
	return 0;
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.