C Program to show an example of Saving Student records to a file # include <fcntl.h> # include <stdio.h> # include <sys/types.h> # include <unistd.h> # include <stdlib.h> struct student { char name [ 20 ] ; int regno , s1 , s2 , s3 ; float total , avg ; } ; struct student var , temp ; int fileSize ( ) { int length ; int des ; des = open ( "stud.txt" , O_RDONLY ) ; length = lseek ( des , 0 , SEEK_END ) ; return length ; } int getNoOfRecords ( ) { return ( fileSize ( ) / ( sizeof ( struct student ) ) ) ; } void addStudentRecord ( ) { int f , fp = open ( "stud.txt" , O_CREAT | O_RDWR | O_APPEND ) ; printf ( "Enter the name:" ) ; scanf ( "%s" , temp . name ) ; printf ( "Enter the reg number:" ) ; scanf ( "%d" , & temp . regno ) ; printf ( "Enter the marks in ...
Get the latest unboxing and tech news at you fingertips. Collect Software and other precious data overtime