Question: How do I programmatically save the output of "C" code generation to a "cpp" file?

How do I programmatically save the output of "C" code generation to a "cpp" file? I am doing all of these in Matlab via the Maple engine, which is version 10, I guess. I cannot seem to do "writeto" redirection here, because Matlab doesn't allow that I guess. And I like to use "fprintf" because it gives me more control of the code that is generated... If it works, I no longer need copy and paste.. But it didn't work at all. There was no error message, but the file was empty... Can anybody tell me why? Thanks! -------------------- fd:=fopen("trygenC.cpp", WRITE, TEXT) aa:=proc(x, m) S:=Array([0, 0]); for k from 1 to m do S[1]:=S[1]+x[1, k]; S[2]:=S[2]+(x[2, k])^2; od; S end proc bb:=prep2trans(aa) cc:=C(bb, optimized) fprintf(fd, %Q, C(bb, optimized)) fclose(fd)
Please Wait...