-2

I'm trying to send commands through the console output via std::cout to a command-line program that I started with fopen("foo.exe","w"). I want to wait until the process has finished before continuing executing my main application. For some reason this crashes my application. Is there a better way of starting the command-line program and sending console outputs?

Thanks a lot!

Nhat

  • You should read the standard library documentation before you try staring a process that way. Won't work. Moink! – Captain Obvlious Feb 13 '14 at 23:43
  • `std::cout` is "character out", as opposed to `std::wcout` (which is "wide character out"). They both write to stdout. Often, stdout is associated with a terminal. There is nothing about a "console" here. Do not conflate stdout with a terminal, and stop calling your terminal a "console". Most terminals are not consoles. – William Pursell Feb 19 '22 at 19:40

1 Answers1

0

You need popen() and pclose(), not fopen() - hope you are speaking of Linux or any POSIX compliant OS.

See here for example - you can find thousands of them.

Sigi
  • 4,826
  • 1
  • 19
  • 23