String input output

I’m trying to take input strings for different test cases…
strings are sentences…
how do I take input and print those for all the test cases…

I have tried two ways to take it but printing it…
https://ide.codingblocks.com/#/s/14145

https://ide.codingblocks.com/#/s/14147

check pls… how do take inputs !!

For your first solution, you are giving input as:
2
vsndskl sbckdj sckjn.
ckdlc d cnksjc

When you try to give input as 2 then (pressing enter or ‘\n’) then your arr[0] is reading blank as for getline() the default delimiter is ‘\n’ Therefore, you need to provide cin.get() before ‘for()’ to avoid reading this ‘\n’.
I have modified your code and have added comments where corrections was required:
https://ide.codingblocks.com/#/s/14183

1 Like