"#include <iostream>
using namespace std; int main() { int i=0, test; char text[200]; cin >> test;
for(int m=0; m<=test; m++) { cin.getline(text,200); while(text[i]) {i++;} i=i/2; for(int k=0; k<i; k+=2) {cout << text[k];} cout << "\n";
} }
try this
3 qwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyui hello world
and then try a string with 200 characters.
Thank you! So it seems my problem was not resetting the array nor the “i”. Editing those and submitting again worked like a charm. Again, thanks man. Really appreciate the prompt inspection.
I think you also need to size the array to 201 to allow for the null terminator.
Yeah, forgot about that as well. But as the string will be halved, what’s the consequence of using 200 instead of 201? I have run with a 200 character string, but couldn’t see any deviations.
What happens here if the null string terminator is missing? It may work, but might not, so why take the chance?