Guest User

Untitled

a guest
Oct 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<string.h>
  4. int main()
  5. {
  6. char* name[]={"Mamun", "Rana", "Tanha", "Sonia","Anika","Siam", "Tonni","Lipi","Rajon","Hasan"};
  7. float CGPA[]={3.40,3.56,3.80,3.56,3.6,3.00,3.25,2.85,3.12,3.01};
  8. char* getname;
  9. float getCGPA;
  10. int i;
  11. FILE* fp;
  12. fp=fopen("c:\\student.txt","w");// create new file
  13. for (i=0; i<10;i++)
  14. {
  15. fprintf(fp,"%-10s%1.2f\n",name[i],CGPA[i]);
  16. }
  17. fclose(fp);
  18. // need to see the output.TO see the output I have used "r"
  19. fp=fopen("c:\\student.txt","r");
  20. while(fscanf(fp,"%s%f",&getname,&getCGPA) != NULL)
  21. {
  22. printf("%-10s %1.2f\n",getname,getCGPA);
  23. }
  24. getch();
  25. return 0;
  26.  
  27. }
Add Comment
Please, Sign In to add comment