Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #include <stdio.h>
- #include <io.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- AnsiString File_Zap;
- FILE *pFile;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- Memo1->Clear();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- Memo1->Clear();
- OpenDialog1->Title="Открыть файл";
- if (OpenDialog1->Execute()) {
- File_Zap = OpenDialog1->FileName;
- if ((pFile=fopen(File_Zap.c_str(),"rb, ccs=UTF-8"))==NULL) {
- ShowMessage("Ошибка открытия ФАЙЛА!");
- return;
- }
- }
- char i;
- int words = 1;
- int test;
- int count[255];
- for(int n=0;n<255;n++)count[n] = 0;
- while(1)
- {
- i = fgetc(pFile);
- if(i == EOF)
- {
- fclose(pFile);
- break;
- }
- else
- {
- //Memo1->Lines->Add(i);
- if(i == ' ') words ++;
- if((i>=65 && i<=90) || (i>=97 && i<=122) || (i>=128 && i<=175) || (i>=224 && i<=241) )
- count[i] ++;
- }
- }
- Memo1->Lines->Add("Words: "+IntToStr(words));
- for(int j=0;j<255;j++)
- {
- if(count[j] != 0)
- {
- char txt[32];
- sprintf(txt, "0 - %d",count[j]);
- txt[0] = j;
- Memo1->Lines->Add(txt);
- }
- }
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement