[Solved] C Programming: error: expected ‘)’ before string constant [closed]


String literals can be concatenated like that, but string values cannot.

Further, it seems that you want the output of gcommand to end up in the buffer output.

It is not possible to do that with the system function. Assuming you are going to be executing in a POSIX-style shell where > is the shell redirection operator, the thing to the right of it must be a file name (or descriptor) in the shell.

To execute a command and capture the output, one way is to use the POSIX popen function:

FILE *pipe = popen(gcommand, "r");
char output[100] = { 0 };

if ( pipe )
{
    fgets(output, sizeof output, pipe);
    pclose(pipe);
}

return output;

solved C Programming: error: expected ‘)’ before string constant [closed]