0

I want to add the lines outputted by the code below into a vector<string>. Is there an easy way to do this directly without having to save the output to a text file then parsing the file?

char command[50] = 'ls - l';
system(command)
  • What would the `vector` store; one string per line? – Ryan Zhang Jul 06 '22 at 17:59
  • There's no way using `system`. There is a more complicated way which involves creating a separate process and capturing the standard output from that process. But how you do that varies depending on what operating system you are working with. – john Jul 06 '22 at 17:59
  • Yes, I would like the vector to store one line at a time – user18884655 Jul 06 '22 at 18:04

0 Answers0