#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int T;
char J[100], S[100];
int count=0;
cin >> T;
while(T--)
{
cin.getline(J,100);
cin.getline(S,100);
puts(J);
puts(S);
for(int i=0; J[i]!='\0'; i++)
{
for(int j=0; S[j]!='\0'; j++)
{
count++;
for(int k=j; S[k]!='\0'; k++)
S[k]=S[k+1];
break;
}
}
cout << count;
}
return 0;
}
I am taking input string in J,S but during execution of program it skips the second input from the console cin.getline
I takes the test cases then takes the Strings J and S
it takes J successfully but fails to get S string ?
you need to be using a string , std::string, and calling getline as in
and then if you want to iterate over the contents of the strings by individual characters
use the iterators, and deference them to get the actual character values. Stay way from c strings as much as possible.