Using File Handling concept in C programming, write the C programs for the following:
(a) To create and store student information of 10 MCA students in a .dat file.
(b) To edit the file created in (a) to add data for 2 more students.
(c) To delete specific line(one student record) from a file.
(a) To create and store student information of 10 MCA students in a .dat file:
#include <stdio.h>
#include <stdlib.h>
#define MAX_STUDENTS 10
struct Student {
int roll_number;
char name[50];
char address[100];
int age;
};
int main() {
struct Student students[MAX_STUDENTS];
int count;
FILE *fp;
fp = fopen("students.dat", "wb");
if (fp == NULL) {
printf("Error opening file! ");
exit(1);
}
printf("Enter the number of MCA students: ");
scanf("%d", &count);
for (int i = 0; i < count; i++) {
printf("Enter details of student %d ", i + 1);
printf("Enter roll number: ");
scanf("%d", &students[i].roll_number);
printf("Enter name: __________ __________ ____ __________ _______.
_________ __________ ____ __________ ________ ____.
___ _________ ___ __________ ___.
_______ _________ ________ __________ _________.
_______ ___ ____ _________ __________ ________ _________ ___ __________.
____ ___ ________ ______ ______.
___ __________ ___ _________ __________ ________ ___ _____ ________ _________ ______.
______ _______ _________ ______ __________.
__________ ____ ______ _________ ____ _________ _________.
________ _______ __________ _____ ______ ________ _______ ___.
_______ __________ ____ _________ _____ ___ _____ ___ _______ _______ _________ ____.
_____ ___ ___ ________ ________ ___.
________ _____ _________ _________ ______ ______ _____ ___ ___ __________.
__________ ________ ______ _______ ______ ______ _________ _________ ____ ___ _________.
_______ _______ __________ _________ _______ __________ __________.
____ ____ _______ __________ __________ _____ ____ ______ _______ __________ _________.
______ _______ _________ ______ _____.
_________ _____ ____ ________ ___ ____ ________ ____ ________ ________ _____.
_____ _________ ____ __________ ___ __________ _____.
______ ______ _______ _________ ______ __________.
________ _________ ___ _________ _____ _______ _______ __________ __________ _______ ______ __________.
__________ _______ ___ __________ ________ _________ __________ _________ ________ ___ __________.
______ ___ ______ ______ ______.
______ ____ _______ ______ __________.
___ _______ _________ ___ __________ _______ _____ ____ ________ ____ ________ ____.
___ ______ __________ ___ _______.
__________ _________ _____ ___ _________ ___ ______ ______ _____ __________ _______ _________.
____ ___ _____ __________ _____ _______ ______ _________ _______ __________ _______.
_________ _________ _______ _________ ___ _____ _____ ____ _____ _______.
_____ _________ _______ ____ __________ _______ ____ _____ ______.
__________ ________ _______ _________ _______ ______ ___ _______.
___ ______ ___ ____ __________.
_________ _____ _________ ______ ____.
____ _____ ______ _________ ______ _________ ______ __________.
___ __________ _______ _________ ___.
___ ___ ______ _____ ____ _______.
_______ _________ ____ ______ _______ _________ _______ __________.
_______ ________ __________ __________ __________ ________ __________ ________ _________ _______.
___ ______ _______ ________ ______ ______ _________ __________.
__________ _______ ________ _______ _______ _________ ________ _______ _________ ____ __________ _____.
________ ______ _____ ______ _______ ___ ________ ________ ________ _________ ___ _______.
__________ ____ ___ ________ _____.
__________ ________ ______ __________ ______ ______ __________ _____ _________.
_________ ______ _______ _____ ________ __________ _____ _____ ______ _________ _____ __________.
____ _____ ______ _________ _______ _______.
_____ _______ ________ ________ __________ ________ __________ ________ ______ __________ ________.
____ ___ _____ ____ _____ _______ ________ ____.
_____ ___ _____ _______ _________ __________ _____.
__________ _________ _____ ____ _______.
_____ ____ ________ _________ ___ ______.
___ ________ __________ ________ ___.
____ __________ ___ ____ ________ _____ _________ _______ ___ ___.
___ ___ __________ _____ ____ _____ _____ _______ ______ ___.
___ ____ ______ ______ ____.
____ __________ ________ ___ _____ ______ ____ _______ ________ _______ _____.
_________ ________ ______ _______ _____ _______ ___ ______ ___ ______ ____ _____.
__________ __________ _____ _______ ______ ______ _________.
_____ ____ ___ ___ _________.
______ ________ _______ ______ _____ ______ __________ ___.
___ ___ ___ ____ __________ _________ ______ ________ __________ ___ _________.
______ _______ _______ ________ ________ ____ ___.
________ ________ _______ ______ __________ ____ ______ ______ ____ _________ ______ ___.
___ _________ _________ ___ _______ _____ _______ ____.
_________ __________ __________ ______ _______.
________ ______ _________ _____ ____ __________ ______ _____ ____ ________.
____ __________ ___ _________ _____ ____ _________ ____.
______ ________ ___ _________ ___.
_______ ______ _____ ________ _________.
____ ____ _______ _____ __________ ____ __________ _____ _______ ______ ____.
_______ _______ ________ ________ _______ ____ _______ ___.
____ ____ ____ _______ __________ ___ __________ _____.
_____ ______ ___ _________ ___ _____ _____ ________ ____ ___.
______ ________ ________ ____ ______ _________ ______.
____ _________ ______ ____ _____.
_____ ______ ___ ________ __________ ________ _____.
_________ ________ ______ ______ ________ ____ ____ ______ _____ ___ _________ _________.
_____ ____ _____ __________ _______.
_______ _____ _________ ___ ____ ________.
__________ _______ _______ __________ ________ ____ _____ ______ ________ ________.
________ ________ _________ ___ __________ ___ _________.
____ __________ ________ __________ _______ _______ ________.
________ _______ _________ _____ _______.
_________ ________ _____ _________.
Get Full Answer on WhatsApp