The way you are trying to capture the output of grep may not work.
Based on the post:
C: Run a System Command and Get Output?
You can try the following. This program uses popen()
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char *argv[] )
{
    FILE *fp;
    int status;
    char path[1035];
    /* Open the command for reading. */
    fp = popen("/bin/ps -x | /usr/bin/grep gnome-sudoku", "r"); 
    if (fp == NULL) {
        printf("Failed to run command\n" );
        exit;
    }
    /* Read the output a line at a time - output it. */
    while (fgets(path, sizeof(path)-1, fp) != NULL) {
      printf("%s", path);
    }
    pclose(fp);
return 0;
}
For reference to popen() see:
http://linux.die.net/man/3/popen
And if you try to use grep then you can probably redirect the output of grep and read the file in the following way:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main() {
    int res = system("ps -x | grep SCREEN > file.txt");
    char path[1024];
    FILE* fp = fopen("file.txt","r");
    if (fp == NULL) {
      printf("Failed to run command\n" );
      exit;
    }
    // Read the output a line at a time - output it.
    while (fgets(path, sizeof(path)-1, fp) != NULL) {
      printf("%s", path);
    }
    fclose(fp);
    //delete the file
    remove ("file.txt");
    return 0;
}