Here's a terminal command:
awk '/^Mem/ {print $4}' <(free -m)
Here's my code:
class CSystemInfo{
public:
    std::string free_ram(){
        std::string s;
        FILE *in;
        char buff[512];
        //here is a prepared string (but with an error)
        if(!(in = popen("awk '/^Mem/ {print $4 \"\\t\"}' <(free -m)","r"))){
        return "";  
        }
        while(fgets(buff, sizeof(buff), in)!=NULL){
            cout << s;
            s=s+buff;
        }
        pclose(in);
        return s;
       }
};
    CSystemInfo info;
    std::string ram = info.free_ram();
    cout << ram;
The above code, when run, returns this message:
sh: 1: Syntax error: "(" unexpected
How can I place the '/' symbol, for this command to work correctly?
sh- is not supporting<(free -m)syntax. Consider invokingbash.bashthat supports this syntax, whilepopenruns insh, more primitive, low-level shell. Tryecho $0. I have just tried running your command insh, it failed with the same message.