kill textrdit program

Dear All:
I use sun OS system and write a code in c as folloing
purpose kill textedit program,but i get some error
please give me a great help Thanks.

#include <stdlib.h>
int main()
{
const char cTestPrag[]=" kill -9 `ps -ef | grep textedit | grep -v "grep"| awk '{print $2}'| xargs` ";

system(cTestPrag);

return 0;
}

#include <stdlib.h>
int main()
{
   char cTestPrag[128]={0x0};
   
   sprintf(cTestPrag, "kill -9 `ps -ef | grep textedit | grep -v %cgrep%c| awk '{print $2}'` ",
       '"','"');
   system(cTestPrag);

   return 0;
}

More easily, just escape the quotes in the string.

const char cTestPrag[]=" kill -9 `ps -ef | grep textedit | grep -v \"grep\"| awk '{print $2}'| xargs` ";

Dear jim mcnamara
Could you explain the code to me because i can't understand them

thanks

You cannot imbed " in a quoted string. You can escape them \" (which linters - code checkers - usually complain about), or you can use sprintf to place them in the string as single characters.

man sprintf

what is the need for quoting grep as "grep" ?

is that going to make any difference ? It won't.

maybe its not working on sun but whats about 'killall' ?