Printf interface

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.

1 Like

Hi, doesn’t ofstream do the job?

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

You can try to do this!

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);

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

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

no problem see function like

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

I have build a small starting exemple

printf.edp (49 Bytes)
printf.cpp.edp (1.9 KB)

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

Bon courage,

Thanks Frederic for preparing this. I’ll try :slight_smile: