CForm[expr]
prints as a C language version of expr.
CForm
CForm[expr]
prints as a C language version of expr.
Examples
open all close allBasic Examples (1)
Scope (1)
Applications (1)
Properties & Relations (2)
When an input evaluates to CForm[expr], CForm does not appear in the output:
CForm[x ^ 2]Out is assigned the value x2, not CForm[x^2]:
%CForm formats expressions like C code:
CForm[1 + 2x + 3x ^ 2]FortranForm formats expressions like Fortran code:
FortranForm[1 + 2x + 3x ^ 2]Possible Issues (2)
Names of functions output by CForm may be different from the names used by the specific C library:
CForm[BesselJ[x, 7]]In order to compile the C code generated, a header file found at the following location may need to be included:
FileNameJoin[{$InstallationDirectory, "SystemFiles", "IncludeFiles", "C", "mdefs.h"}]Even when an output omits CForm from the top level, it is not stripped from subexpressions:
e = CForm[x ^ 2]The output does not have CForm in it:
%However, the variable e does have CForm in it, which may affect subsequent evaluations:
FullForm[e]The product is not evaluated due to the intervening CForm:
x * eAssign variables first and then apply CForm to the result to maintain computability:
(f = x ^ 2)//CFormx * fTech Notes
Related Guides
History
Introduced in 1988 (1.0)
Text
Wolfram Research (1988), CForm, Wolfram Language function, https://reference.wolfram.com/language/ref/CForm.html.
CMS
Wolfram Language. 1988. "CForm." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CForm.html.
APA
Wolfram Language. (1988). CForm. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CForm.html
BibTeX
@misc{reference.wolfram_2026_cform, author="Wolfram Research", title="{CForm}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/CForm.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_cform, organization={Wolfram Research}, title={CForm}, year={1988}, url={https://reference.wolfram.com/language/ref/CForm.html}, note=[Accessed: 15-June-2026]}