Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <fstream.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- mmSubor->Lines->LoadFromFile("mena.txt");
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- mmSubor->Lines->SaveToFile("mena.txt");
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button3Click(TObject *Sender)
- {
- ofstream f;
- f.open("Vystup.txt");
- f.put('A');
- f.put('B');
- f.put('\n');
- f.put('C');
- f.close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button5Click(TObject *Sender)
- {
- ofstream f;
- f.open("VelkaAbeceda.txt");
- for (char i = 'A'; i <= 'Z'; i++) {
- f.put(i);
- if ( i != 'Z' ) {
- f.put(' ');
- }
- }
- f.close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button4Click(TObject *Sender)
- {
- ofstream f;
- f.open("moje-meno.txt");
- AnsiString str = "Roman\nVaĊĦek";
- for (int i = 1; i <= str.Length(); i++) {
- f.put(str[i]);
- }
- f.close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button6Click(TObject *Sender)
- {
- ofstream f;
- f.open("za.txt");
- for (char i = 'z'; i >= 'a'; i--) {
- f.put(i);
- if ( i != 'a' ) {
- f.put(' ');
- }
- }
- f.close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button7Click(TObject *Sender)
- {
- ofstream f;
- char c,m;
- f.open("0123.txt");
- for (c = '0'; c <= '9'; c++) {
- for (m = '0';m<c; m++) f.put(' ');
- f.put(c);
- f.put('\n');
- }
- f.close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button8Click(TObject *Sender)
- {
- ifstream f;
- char c;
- int i;
- f.open("vstup.txt");
- if ( f.fail() ) {
- ShowMessage("Chyba pri otvarani!");
- } else {
- Label2->Caption = "";
- for (i = 1; i<=8; i++) {
- f.get(c);
- Label2->Caption=Label2->Caption + c;
- }
- f.close();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button9Click(TObject *Sender)
- {
- ifstream f;
- AnsiChar c;
- int i;
- f.open("moje-meno.txt");
- if ( f.fail() ) {
- ShowMessage("Chyba pri otvarani!");
- } else {
- Label2->Caption = "";
- while ( f.good() ) {
- f.get(c);
- Label2->Caption=Label2->Caption + c;
- }
- f.close();
- }
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment