GamerSK

subory

Feb 7th, 2019
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.10 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #include <fstream.h>
  5. #pragma hdrstop
  6.  
  7. #include "Unit1.h"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma resource "*.dfm"
  11. TForm1 *Form1;
  12. //---------------------------------------------------------------------------
  13. __fastcall TForm1::TForm1(TComponent* Owner)
  14.     : TForm(Owner)
  15. {
  16. }
  17. //---------------------------------------------------------------------------
  18. void __fastcall TForm1::Button1Click(TObject *Sender)
  19. {
  20.     mmSubor->Lines->LoadFromFile("mena.txt");
  21. }
  22. //---------------------------------------------------------------------------
  23. void __fastcall TForm1::Button2Click(TObject *Sender)
  24. {
  25.     mmSubor->Lines->SaveToFile("mena.txt");
  26.  
  27. }
  28. //---------------------------------------------------------------------------
  29. void __fastcall TForm1::Button3Click(TObject *Sender)
  30. {
  31.     ofstream f;
  32.     f.open("Vystup.txt");
  33.     f.put('A');
  34.     f.put('B');
  35.     f.put('\n');
  36.     f.put('C');
  37.     f.close();
  38. }
  39.  
  40. //---------------------------------------------------------------------------
  41.  
  42. void __fastcall TForm1::Button5Click(TObject *Sender)
  43. {
  44.     ofstream f;
  45.     f.open("VelkaAbeceda.txt");
  46.     for (char i = 'A'; i <= 'Z'; i++) {
  47.         f.put(i);
  48.         if ( i != 'Z' ) {
  49.             f.put(' ');
  50.         }
  51.     }
  52.     f.close();
  53. }
  54. //---------------------------------------------------------------------------
  55.   void __fastcall TForm1::Button4Click(TObject *Sender)
  56. {
  57.     ofstream f;
  58.     f.open("moje-meno.txt");
  59.     AnsiString str = "Roman\nVaĊĦek";
  60.     for (int i = 1; i <= str.Length(); i++) {
  61.         f.put(str[i]);
  62.     }
  63.     f.close();
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TForm1::Button6Click(TObject *Sender)
  67. {
  68.     ofstream f;
  69.     f.open("za.txt");
  70.     for (char i = 'z'; i >= 'a'; i--) {
  71.         f.put(i);
  72.         if ( i != 'a' ) {
  73.             f.put(' ');
  74.         }
  75.     }
  76.     f.close();
  77. }
  78. //---------------------------------------------------------------------------
  79.  
  80. void __fastcall TForm1::Button7Click(TObject *Sender)
  81. {
  82.     ofstream f;
  83.     char c,m;
  84.     f.open("0123.txt");
  85.     for (c = '0'; c <= '9'; c++) {
  86.         for (m = '0';m<c; m++) f.put(' ');
  87.         f.put(c);
  88.         f.put('\n');
  89.     }
  90.     f.close();
  91. }
  92. //---------------------------------------------------------------------------
  93.  
  94. void __fastcall TForm1::Button8Click(TObject *Sender)
  95. {
  96.     ifstream f;
  97.     char c;
  98.     int i;
  99.     f.open("vstup.txt");
  100.     if ( f.fail() ) {
  101.         ShowMessage("Chyba pri otvarani!");
  102.     } else {
  103.         Label2->Caption = "";
  104.         for (i = 1; i<=8; i++) {
  105.             f.get(c);
  106.             Label2->Caption=Label2->Caption + c;
  107.         }
  108.         f.close();
  109.     }
  110.  
  111. }
  112. //---------------------------------------------------------------------------
  113.  
  114. void __fastcall TForm1::Button9Click(TObject *Sender)
  115. {
  116.     ifstream f;
  117.     AnsiChar c;
  118.     int i;
  119.     f.open("moje-meno.txt");
  120.     if ( f.fail() ) {
  121.         ShowMessage("Chyba pri otvarani!");
  122.     } else {
  123.         Label2->Caption = "";
  124.          while ( f.good() ) {
  125.             f.get(c);
  126.             Label2->Caption=Label2->Caption + c;
  127.         }
  128.         f.close();
  129.     }
  130. }
  131. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment