I'm using "mathlink.h" to call Mathematica from a C program. I send a computation to Mathematica and its return result is a very big number (100 digits). Hence, I want to read that number as a string.
How can I do it using MathLink?
Thanks,
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI'm using "mathlink.h" to call Mathematica from a C program. I send a computation to Mathematica and its return result is a very big number (100 digits). Hence, I want to read that number as a string.
How can I do it using MathLink?
Thanks,
You could simply wrap your computation in
MLPutFunction(link, "ToString", 1);
and convert your result to a string. After that you can use MLGetString
.
ToString[x^2 + x + 1, InputForm]
gives a string of valid Mathematica syntax.
$\endgroup$
– halirutan♦
Oct 21 '13 at 7:36