#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
void Fun(char *s) {
for(int i=0;s[i]!='\0';i++){
while(s[i]!='\0' && s[i]!='.' ){
cout<<s[i];
i++;
}
cout<<" ";
}
}
int main() {
int t;
cin >> t;
while (t--) {
char s[10000];
cin >> s;
Fun(s);
cout<<endl;
}
}
Input :
2
i.like.this.program.very.much
pqr.mno
Output :
i like this program very much
pqr mno his program very much
Why are the characters of my previous string being printed in the next test case even though I've declared the character array again in the while loop ? If I simply print the string using for loop, it prints the right answer, but not this way. I do not get the reason why this is happening?