Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I don't know the difference between fprintf and fputs

fprintf(file, "Hellow");
fputs("Hellow", file);

The results of these two seem to be the same.
I don’t know in what situations these are used differently and what the differences are in execution.

Only the result values ​​of the two are the same and I can’t figure it out anymore.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I solved it thanks to your help. Thank you.

>Solution :

fprintf provides you with the ability to format strings(like printf), while fputs just outputs the string straight to the file handle stream you give it.

This is how they are normally used:

fprintf(file_handle, "this is a number: %d", 10);
fputs("hi", file_handle);

Some good references for these functions are(do some research before asking!):
https://www.tutorialspoint.com/c_standard_library/c_function_fputs.htm
https://www.tutorialspoint.com/c_standard_library/c_function_fprintf.htm

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading