One may want to chain the task of execution of the program and display the function. For this there are two solution; one is to add into the C program a line with
exec("gnuplot | plot 'f.gnu' w l")
If it does not work try replace exec by "system".
The second method is to create a batch file, i.e. a text file say "mybatch" which contains the lines
a.out gnuplot plot "f.gnu" w l
and to change the access rights of the file "mybatch" by
chmod 777 mybatchto allow the command
mybatchto work.