Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct ball
  5. {
  6. char name[50];
  7. int number;
  8. int time;
  9. };
  10. void fill_table(struct ball *bl,int *p);
  11. void show_table(struct ball *bl,int size);
  12.  
  13.  
  14. int main ()
  15. {
  16. struct ball bl[1000];
  17.  
  18. int size;
  19. int *p;
  20. size=0;
  21. p=&size;
  22. fill_table(bl,&size);
  23. show_table(bl,size);
  24.  
  25.  
  26.  
  27.  
  28. return 0;
  29. }
  30.  
  31. void fill_table(struct ball *bl,int *p)
  32. {
  33. int i,x;
  34. FILE *fp;
  35. fp=fopen("player.txt","w");
  36. printf("dwse 1 gia stxia alliws -1 na men se pari kanenas poutsos");
  37. scanf("%d",&x);
  38. if (x==1)
  39. {
  40. for (i=0; i<1000; i++)
  41. {
  42. printf("dwse onoma paiktarou");
  43. scanf("%s",bl[i].name);
  44. printf("dwse arithmo paiktarou");
  45. scanf("%d",&bl[i].number);
  46. printf("dwse xrono paiktarou");
  47. scanf("%d",&bl[i].time);
  48. *p=*p+1;
  49. fprintf(fp,"onoma %s arithmos %d xronos %d/n",bl[i].name,bl[i].number,bl[i].time);
  50. fclose(fp);
  51. printf("dwse 1 gia stxia alliws -1 na men se pari kanenas poutsos");
  52. scanf("%d",&x);
  53. if (x==-1)
  54. break;
  55. }
  56. }
  57.  
  58. }
  59.  
  60. void show_table(struct ball *bl,int size)
  61. {
  62. int i;
  63.  
  64. for (i=0; i<size; i++)
  65. {
  66. printf("\n");
  67. printf("onoma %s arithmos %d xronos %d\n",bl[i].name,bl[i].number,bl[i].time);
  68. printf("\n");
  69. }
  70.  
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement