Write a program that will read your personal information such as name, student id, and home district from the keyboard and save it into a file name myinfo.txt. Then write another program to read information from this txt file and display it as output of your program.
Solution:
#include<stdio.h>
int main()
{
FILE *file;
char name[30];
int id,num,i;
char district[15];
file=fopen("myinfo.txt","a");
if(file==NULL)
printf("not");
else
{
printf("File is open ");
printf("Enter of integer number of student ");
scanf("%d",&num);
for(i=0; i<num; i++)
{
printf("Enter student name ");
scanf("%s",&name);
printf("Enter student ID ");
scanf("%d",&id);
printf("Enter student district ");
scanf("%s",&district);
fprintf(file,"%s %d %s ",name,id,district);
}
fclose(file);
}
}
thistimebd Bangladesh Live online newsportal, education, Lifestyle, Health, Photography, gif image etc.
Make your own name or company name website | contact: thistimebd24@gmail.com
Copyright © 2020-2024 News Portal in Bangladesh - THISTIMEBD.COM. ALL Rights Reserved.