file military_power.txt
France 228656 195770 423 149 60 1203 120 1
USA 1430000 850880 8325 1934 1330 13683 473 10
China 2285000 2300000 9150 1710 1770 2788 520 1
India 1325000 2143000 3569 290 292 1785 184 2
UK 205330 182000 407 89 56 908 66 1
Japan 247746 57900 767 196 99 1595 131 1
Russia 766000 2485000 15500 5990 3781 3082 352 1
Unit1.cpp
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
struct armed_Forces
{
char country[64];
int so;
int re;
int ta;
int ar;
int mi;
int mt;
int mn;
int ac;
};
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Button1->Caption="&OPEN";
Button2->Caption="&CLOSE";
UnicodeString Date[9]={"country","soldiers","reserve","tanks","artillery",
"missyle_systems", "military_aviation","military_navy","aircraft_carriers"};
for(int i=0;i<9;i++)
{
StringGrid1->Cells[i][0]=Date[i];
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
FILE* fp;
int i;
if((fp=fopen("military_power.txt","r"))==NULL)
{
ShowMessage("Error. I can't open the file!");
}
else
{
struct armed_Forces a_F[7];
for(i=0;i<7;i++)
{
fscanf(fp,"%s %d %d %d %d %d %d %d %d\n",a_F[i].country,&a_F[i].so,&a_F[i].re,
&a_F[i].ta,&a_F[i].ar,&a_F[i].mi,&a_F[i].mt,&a_F[i].mn,&a_F[i].ac);
}
for(i=0;i<7;i++)
{
StringGrid1->Cells[0][i+1]=UnicodeString(a_F[i].country);
StringGrid1->Cells[1][i+1]=IntToStr(a_F[i].so);
StringGrid1->Cells[2][i+1]=IntToStr(a_F[i].re);
StringGrid1->Cells[3][i+1]=IntToStr(a_F[i].ta);
StringGrid1->Cells[4][i+1]=IntToStr(a_F[i].ar);
StringGrid1->Cells[5][i+1]=IntToStr(a_F[i].mi);
StringGrid1->Cells[6][i+1]=IntToStr(a_F[i].mt);
StringGrid1->Cells[7][i+1]=IntToStr(a_F[i].mn);
StringGrid1->Cells[8][i+1]=IntToStr(a_F[i].ac);
}
}
}
