# Printf interface

**URL:** https://community.freefem.org/t/printf-interface/800
**Category:** Feature Request
**Created:** [February 12, 2021, 4:49am UTC](https://community.freefem.org/t/printf-interface/800 "2021-02-12T04:49:53Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![arousta](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@arousta](https://community.freefem.org/u/arousta)
#### Post date: [February 12, 2021, 4:49am UTC](https://community.freefem.org/t/printf-interface/800/1 "2021-02-12T04:49:53Z")

</div>

I think it would be great to have printf in freefem. Syntax is shorter (and I believe easier to read) and better fits to the overall style of the freefem code.

---

<div class="post-metadata">

### Author: ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)
#### Post date: [February 12, 2021, 8:54am UTC](https://community.freefem.org/t/printf-interface/800/2 "2021-02-12T08:54:28Z")

</div>

Hi, doesn’t `ofstream` do the job?

> real a1=1.0,a2=2.0;  
> ofstream output(“file.dat”);  
> output \<\< a1 \<\< " "  
> \<\< a2 \<\< " "  
> \<\<endl;

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [February 12, 2021, 12:51pm UTC](https://community.freefem.org/t/printf-interface/800/3 "2021-02-12T12:51:52Z")

</div>

You can try to do this!

---

<div class="post-metadata">

### Author: ![arousta](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@arousta](https://community.freefem.org/u/arousta)
#### Post date: [February 13, 2021, 7:47am UTC](https://community.freefem.org/t/printf-interface/800/4 "2021-02-13T07:47:24Z")

</div>

Yes does the job. But as I mentioned printf is more concise and convenient than long c++ style. Compare your minimal example with something like printf(output,"%f %f\n",a1,a2);

---

<div class="post-metadata">

### Author: ![arousta](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@arousta](https://community.freefem.org/u/arousta)
#### Post date: [February 13, 2021, 7:49am UTC](https://community.freefem.org/t/printf-interface/800/5 "2021-02-13T07:49:14Z")

</div>

Well, if it is not very complicated I can try!  
Can you point me to an example (the simplest) of interfacing with some C code in freefem?  
Merci

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [February 13, 2021, 9:29am UTC](https://community.freefem.org/t/printf-interface/800/6 "2021-02-13T09:29:41Z")

</div>

I’m curious as well to see how to define variadic functions in FreeFEM DSL.

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [May 6, 2021, 2:46pm UTC](https://community.freefem.org/t/printf-interface/800/7 "2021-05-06T14:46:26Z")

</div>

no problem see function like

Global.Add(“adaptmesh”,“(”,new OneOperatorCode);

I have build a small starting exemple

[printf.edp](https://community.freefem.org/uploads/short-url/tTzJuYnmnxbvCaspqpIImHs3WWk.edp) (49 Bytes)  
[printf.cpp.edp](https://community.freefem.org/uploads/short-url/4EMwA2lAhHQGv2m0ZL2b33OIP5c.edp) (1.9 KB)

```
 mv printf.cpp.edp in printf.cpp
 ff-c++ printf.cpp
 FreeFem++ printf.edp 

```

Bon courage,

> [@frederichecht](#):
>
> start

---

<div class="post-metadata">

### Author: ![arousta](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@arousta](https://community.freefem.org/u/arousta)
#### Post date: [May 8, 2021, 11:22pm UTC](https://community.freefem.org/t/printf-interface/800/8 "2021-05-08T23:22:17Z")

</div>

Thanks Frederic for preparing this. I’ll try 🙂
