How to write a C Program To Store Students Record In A Text File in C Programming Language ?
Solution For C Program :
/*C Program To Store Students Record In A Text File.*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
FILE *fp;
char another='y';
int marks1,marks2,marks3,marks4,marks5,role;
char name[20];
clrscr();
fp=fopen("Students.txt","w");
if(fp==NULL)
{
puts("Cannot open file");
exit(1);
}
fprintf(fp,"Role No.\tNAME\t PHYSICS CHEMISTRY MATHS S.S.T ENGLISH\n");
while(another=='y')
{
printf("\nEnter name :");
scanf("%s",&name);
printf("Enter your Role No.:");
scanf("%d",&role);
printf("Enter marks in Physics:");
scanf("%d",&marks1);
printf("Enter marks in Chemistry:");
scanf("%d",&marks2);
printf("Enter marks in Mathematics:");
scanf("%d",&marks3);
printf("Enter marks in Social Science:");
scanf("%d",&marks4);
printf("Enter marks in English:");
scanf("%d",&marks5);
fprintf(fp,"%d\t%s\t%d\t%d\t%d\t%d\t%d\n",role, name, marks1,marks2,marks3,marks4,marks5);
printf("Add another record (y/n): ");
fflush(stdin);
another=getche();
}
fclose(fp);
}
You may also learn these C Program/Code :
C Program To Swap Two Numbers Without Using Third Variable
Learn More :
Text
Store
- C Program To Store Students Record Using Structure
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- C Program to calculate sum of two m*n matrices & store the result in 3 matrix
- C Program to accept n numbers from user store these numbers into an array & calculate average of n numbers
- C Program to accept n numbers & store all prime numbers in an array & display this result
- C program to accept n number from user,store these numbers into an array & count the no of occurrences of each number
- C Program to accept n numbers from user store these numbers into an array & reverse an array elements using function
- C Program to accept 5 names from user & store these names into an array. Sort these array elements in alphabetical order
- C Program to accept n numbers from user,store these numbers into an array & sort the number of an array
- C Program to accept n numbers from user, store these numbers into an array. Find out Maximum & Minimum number from an Array
- C Program to accept data from user store that data into text file
- Find the union and intersection of two sets of integer store it in two array C Program
- Accept n number from user, store these number into an array and calculate the average of n number
- C Program - Hash Table to store information about a student
- C Program to Input Student Details into a File For Two Subjects
File
- COPY DATA FROM ONE FILE TO ANOTHER FILE USING C PROGRAM
- C Program File Input & Output Example
- C Program To Destruc Self Execution File ?
- C Program To Write Data In A File And Search Data From File
- Make a copy of file given in argv[1] to file given in argv[2]
- C Program to copy a file to another file
- C Function to read instructions from the file and obey them
- Client/Server C program to make client send the name of a file
- A small I/O bound program to copy N bytes from an input file to an output file.
- C Program to Read and Write FIFO
- File Number Control C Program Example
- C Program to opens and reads dictionary file specified in spellrc
- C Program to Recursively converts all file-names to lower-case
- C Program to Find the Size of File using File Handling Function
- C Program Recursive function that searches for a given file in a given folder
- C Program Read a char & print next char ( file to file )
- C Program to Input Student Details into a File For Two Subjects
- Identifies the architecture Windows PE (exe or dll) file was compiled C Program
- File Handling (console to file) in C Program
Student