Formatted Mode console
C library has two library functions scanf() and printf() for doing all formatted console input output works. scanf is to read formatted input and printf is to write formatted output.
Formatted output printf
printf takes one fixed argument and can take variable additional arguments. First argument is the format string. Additional arguments depends of formatting string. User has to provide the elements in the same sequence as the format string has been given. printf scans the formatting string and replaces all the %<element> with the text equivalent of the arguments given. This buffer then goes for writing to the output console device. It returns the number of bytes written to the console.
Formatted inputs scanf
scanf takes one fixed argument and can take variable additional arguments. First argument is the format string. Additional arguments depends of formatting string. User has to provide the elements in the same sequence as the format string has been given. scanf reads console input file and scans input buffer as per formatting string and whenever it finds %<element> it converts the element and stores in the address given in the additional arguments. User has to provide the reference of the variables in the arguments in order to receive type objects from file. It returns the number of successful arguments converted successfully.
Formatted Mode example
Entering data for student database First name : John Last name : Carter Class/Std [1-12]: 1 Enrollment number : 2 Score : 85.6 Grade [A-D] : A First name : John Last name : John Class/Std : 1 Roll number : 2 Score : 85.60 Grade : A
About our authors: Team EQA
You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Memory leaks