Advertisement
TShiva

Вывод хуйни c разделением ошибок от обычного вывода, в Popen

Mar 10th, 2017
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <unistd.h>
  3. int main(int argc, char *argv[])
  4. {
  5.     FILE *in;
  6.     char buff[512];
  7.     in = popen("ping -cokcglf 2>&1", "r");
  8.  
  9.    while(fgets(buff, sizeof(buff), in)!=NULL){
  10.       std::cout<<buff;
  11.     }
  12.     auto err = pclose(in);
  13.     std::cerr<< WEXITSTATUS(err);
  14.     return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement