O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using fprintf and scanf Together

The benefit of using formatted data processing in text mode is that the resulting file can be edited by a text editor, and error checking is much easier to enforce. It is also easier to verify that the correct processing has been performed.

However, the ease of editing and ability to view the file directly is its downfall, because files tend to be slightly bloated (an integer in binary format takes much less space for larger numbers) and can be changed by anyone, which is not always desirable. Consider, for example, a game where the data file contains information relating to the challenges that the players might encounter.

The ability to easily edit the file might lead players to cheat—either by looking ahead ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required