Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<string.h>
- int main()
- {
- char* name[]={"Mamun", "Rana", "Tanha", "Sonia","Anika","Siam", "Tonni","Lipi","Rajon","Hasan"};
- float CGPA[]={3.40,3.56,3.80,3.56,3.6,3.00,3.25,2.85,3.12,3.01};
- char* getname;
- float getCGPA;
- int i;
- FILE* fp;
- fp=fopen("c:\\student.txt","w");// create new file
- for (i=0; i<10;i++)
- {
- fprintf(fp,"%-10s%1.2f\n",name[i],CGPA[i]);
- }
- fclose(fp);
- // need to see the output.TO see the output I have used "r"
- fp=fopen("c:\\student.txt","r");
- while(fscanf(fp,"%s%f",&getname,&getCGPA) != NULL)
- {
- printf("%-10s %1.2f\n",getname,getCGPA);
- }
- getch();
- return 0;
- }
Add Comment
Please, Sign In to add comment