0

I did a code long ago in C, that I run with a script shell file. The sh-file does the following

make clean
make

./program.c
echo
cat program.dat
echo END

The code in program.c just has a printf('%f %f', A, B). I am doing a new code, mimicking this idea but after running the code, it will not print it into the new file it just prints it on the terminal. Please help.

Bill Hileman
  • 2,798
  • 2
  • 17
  • 24
RSM
  • 227
  • 2
  • 11
  • 1
    I think this might help you, take a look [here](https://stackoverflow.com/questions/3463426/in-c-how-should-i-read-a-text-file-and-print-all-strings). – Mateus Nov 10 '21 at 18:35
  • I added the following commands: FILE * file; then file = fopen("DATA.dat", "w"); then printf("%f %f", A, B); then fclose(file); – RSM Nov 10 '21 at 18:43
  • By modifying the prinf statement into fprintf(file, "%f %f, A, B); did the trick, it is now printing into a text file. It is still printing into the terminal but idk if it is supposed to do that by default. Thanks a lot. – RSM Nov 10 '21 at 18:49

0 Answers0