Previous | Home | Next |
putw( ) functions: The putw() function is used to write integer into file
It return the integer written to the file on success and EOF on error.
/** Program the understand the use of putw( ) function */ #include<stdio.h> void main() { FILE *fp1; int a ; fp1=fopen("rajesh.dat","wb") // open file for(int a=1; a<=10;a++) // Start loop with 1 and end with 10 { putw(a,fp1) // function is use to write an integer into a file } fclose(fp1) // close file };
Output: This program will write integer from 1 to 10 and store data into the file name "rajesh.dat"
1
2
3
4
5
6
7
8
9
10
Previous | Home | Next |