I get the error "error C3861: popen: identifier not found", if I run through vs code then everything works, but if I run through microsoft vs then the program does not want to compile. How to fix it?
code (c++):
#include <iostream>
#include <string>
#include <cstdlib>
int main() {
std::string result = "";
FILE* pipe = popen("some command 2>&1", "r"); //error
char buffer[128];
while(!feof(pipe)) {
if(fgets(buffer, 128, pipe) != NULL)
result += buffer;
}
pclose(pipe); //error
std::cout << "res :" << result;
return 0;
}
>Solution :
If you are on Windows, it might be _popen() and _pclose()
Try this:
FILE* pipe = _popen("some command 2>&1", "r");