C fprintf() and fscanf()Writing File : fprintf() functionThe fprintf() function is used to write set of characters into file. It sends formatted output to a stream. Syntax: Example: Reading File : fscanf() functionThe fscanf() function is used to read set of characters from file. It reads a word from the file and returns EOF at the end of file. Syntax: Example: Output: Hello file by fprintf... C File Example: Storing employee informationLet's see a file handling example to store employee information as entered by user from console. We are going to store id, name and salary of the employee. Output: Enter the id 1 Enter the name sonoo Enter the salary 120000 Now open file from current directory. For windows operating system, go to TC\bin directory, you will see emp.txt file. It will have following information. emp.txt Id= 1 Name= sonoo Salary= 120000
Next TopicC fputc() and fgetc()
|
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week