Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Re: On CForm and Saving' topicStudent Support Forum > General > Archives > "Re: On CForm and Saving"

Help | Reply To Topic
Author Comment/Response
Elizabeth Earhart
05/20/97 6:08pm

Reply to message #363 from jagadeesh: > am trying to convert a variable
,say, > var = d^3 to Cform and then saving to > a file using Save
command. When I use > CForm[var], on the front end it gives > Power(d,3)
and when i save it, it saves > it as CForm[d^3] only. Power(d,3) is
more convenient to change to pow(d,3) > as required by C language
> than something like CForm[d^3]. I have > expressions which have
30 to 40 such variables. So it is a pain trying to change everything
manually. Any help will be greatly apprerciated. > Try wrapping CForm
in ToString. In fact, you can do StringReplace[ ToString[CForm[d^3]],
{''Power''->''pow''}], and then you won't have to manually change
the variables to useful form. I have a 2.2 notebook that I used to
generate a (huge) C file for use in MathLink, if you'd like to see
an example. -Elizabeth

URL: ,
Help | Reply To Topic