Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
map_file_mangling
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86 #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <iostream> #include <string> FILE* PipeOpen(const char* command, const char* type) { #if defined (_MSC_VER) return _popen(command, type); #else return popen(command, type); #endif } int PipeClose(FILE* stream) { #if defined (_MSC_VER) return _pclose(stream); #else return pclose(stream); #endif } std::string RunCommand(const std::string& cmd, bool verbose = false) { FILE* pipe(PipeOpen(cmd.c_str(), "r")); char buffer[1024]; std::string output = ""; while (!feof(pipe)) { if (fgets(buffer, 1024, pipe) != NULL) output += buffer; } PipeClose(pipe); if (verbose) std::cout << "---------\n" << "RunCommand: " << cmd << '\n' << "---------\n" << std::endl; return output; } int main() { std::cout << RunCommand("cd.. & dir & type cl.bat", true) << std::endl; std::cout << "Hello, world!\n"; }
run
|
edit
|
history
|
help
0
constexpr internal error
#21
Regex pipe and tabs c++
C++ standard violation: [templates][explicit instantiation][access checking]
du
hgh
dharm1
Implements.cpp
ㅇㅇ
#22.2