The −c option expects an argument in a single argv member which is the entire command to be parsed and executed. Note that you don't have to remove any trailing \n from the line, because that doesn't affect the semantics of the shell command!
Sample call shown in class:
execl("/bin/sh", "sh", "-c", "ls | tr -ef", (char *)NULL); perror("/bin/sh"); exit(1);
Of course you can use a string variable instead of the "ls | tr −ef" above.