Jump to content

*.txt(Not Defterine) Dosyasına Kayıt Yapmak


Muallim-i Ali

Recommended Posts

Ekleyen : afish

 1. #include   <iostream.h> 
2. #include <conio.h>
3. #include <fstream.h>
4. #include <iomanip.h>
5.
6.
7. int gun,ay,yil,biz,onlar,kontrol=0;
8. char saha;
9.
10. void kayit()
11. {
12. int kayitSayisi,i;
13. cout<<"dosyaya kac kayit yapilacak ?"<<endl;
14. cin>>kayitSayisi;
15. ofstream futbol;
16. futbol.open("skor.txt",ios::out);
17. for(i=0;i<kayitSayisi; i++)
18. {
19. cout<< " verileri giriniz ?"<<endl;
20. cin>>gun>>ay>>yil>>saha>>biz>>onlar;
21. futbol << gun<<setw(3)<<setw(3)<<ay<<setw(3)<<yil<<setw(3)<<saha<<setw(3)<<biz<<setw(3)
22. <<onlar<<setw(3)<<endl;
23. }
24. futbol.close();
25. getch();
26. }
27.
28.
29.
30. void kayitIlave()
31. {
32. int ilaveKayit,i;
33. cout<<"dosyaya kac kayit ilave edilecek ?"<<endl;
34. cin>>ilaveKayit;
35. ofstream futbol;
36. futbol.open("skor.txt",ios::app);
37. for(i=0;i<ilaveKayit; i++)
38. {
39. cout<< " verileri giriniz ?"<<endl;
40. cin>>gun>>ay>>yil>>saha>>biz>>onlar;
41. futbol << gun<<ay<<yil<<saha<<biz<<onlar<<endl;
42. }
43. futbol.close();
44. getch();
45. }
46.
47. void liste()
48. {
49. clrscr();
50. ifstream futbol;
51. futbol.open("skor.txt",ios::in);
52. while(futbol>>gun>>ay>>yil>>saha>>biz>>onlar)
53. {
54. cout<< gun<<ay<<yil<<saha<<biz<<onlar<<endl;
55. cout<endl;
56. }
57. futbol.close();
58. getch();
59. }
60.
61. void silme()
62. {
63. int silinecekYil;
64. clrscr();
65. cout<<"silinecek yil giriniz "<<endl;
66. cin>>silinecekYil;
67. ifstream futbol;
68. futbol.open("skor.txt",ios::in);
69. ofstream gecici;
70. gecici.open("gecici.txt",ios::out);
71. while(futbol>>gun>>ay>>yil>>saha>>biz>>onlar)
72. {
73. if(silinecekYil!=yil)
74. {
75. gecici << gun<<ay<<yil<<saha<<biz<<onlar<<endl;
76. }
77. }
78.
79.
80. futbol.close();
81. gecici.close();
82.
83. // copy temp to milan
84. ifstream f1("gecici.txt");
85. ofstream f2("skor.txt");
86. f2<<f1.rdbuf();
87.
88. }
89.
90.
91. void sorgu()
92. {int yilAra;
93. cout<<"hangi yila ait kayitlari araniyor ?"<<endl;
94. cin>>yilAra;
95. ifstream futbol;
96. futbol.open("skor.txt",ios::in);
97. while(futbol>>gun>>ay>>yil>>saha>>biz>>onlar )
98. {
99. if(yilAra==yil)
100. cout<< gun<<ay<<yil<<saha<<biz<<onlar<<endl;
101. }
102. futbol.close();
103. getch();
104. }
105.
106.
107. void menu()
108. {
109. int secim;
110. clrscr();
111. while(kontrol==0)
112. {
113. cout<<"[1] - Kayit " <<endl;
114. cout<<"[2] - Kayit Ilave " <<endl;
115. cout<<"[3] - Silme " <<endl;
116. cout<<"[4] - Liste " <<endl;
117. cout<<"[5] - sorgu " <<endl;
118. cout<<"[6] - Cikis " <<endl;
119. cout<<"Seciminiz:"<<endl;
120. cin>>secim;
121. if(secim==1) kayit();
122. if(secim==2) kayitIlave();
123. if(secim==3) silme();
124. if(secim==4) liste();
125. if(secim==5) sorgu();
126. if(secim==6) kontrol=1;
127. else menu();
128. }
129. }
130. void main()
131. {
132. menu();
133. }
[/CODE]

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...