• 15 апреля стартует «Курс «SQL-injection Master» ©» от команды The Codeby

    За 3 месяца вы пройдете путь от начальных навыков работы с SQL-запросами к базам данных до продвинутых техник. Научитесь находить уязвимости связанные с базами данных, и внедрять произвольный SQL-код в уязвимые приложения.

    На последнюю неделю приходится экзамен, где нужно будет показать свои навыки, взломав ряд уязвимых учебных сайтов, и добыть флаги. Успешно сдавшие экзамен получат сертификат.

    Запись на курс до 25 апреля. Получить промодоступ ...

Проблемка с прогой

  • Автор темы ShawnDark
  • Дата начала
S

ShawnDark

Вот делаю прогу, верней переделываю, немного поменял, изменил значения StringGrid1,3 и теперь пишет ошибку:

Вот весь текст программы:
Код:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include "Unit2.h"
#include "Unit5.h"
#include "Unit3.h"
#include "Unit6.h"
#include "Unit4.h"
#include "Unit7.h"
#include "Unit8.h"
#include <fstream.h>

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------



void __fastcall TForm1::Button5Click(TObject *Sender)
{
Form1->Enabled=false;
Form2->Show();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
StringGrid1->Cells[0][0] = " Код";
StringGrid1->Cells[1][0] = " Наименование";
StringGrid1->Cells[2][0] = " Кол-во";
StringGrid1->Cells[3][0] = "	 Цена";
//StringGrid1->Cells[4][0] = "	 Цена";

StringGrid2->Cells[0][0] = " Код";
StringGrid2->Cells[1][0] = " Имя";
StringGrid2->Cells[2][0] = "	 Адрес";
StringGrid2->Cells[3][0] = "	 Телефон";

StringGrid3->Cells[0][0] = " №";
StringGrid3->Cells[1][0] = " Дата";
StringGrid3->Cells[2][0] = " Имя";
StringGrid3->Cells[3][0] = "	Товар";
StringGrid3->Cells[4][0] = " Количество";
StringGrid3->Cells[5][0] = " Сумма";
//StringGrid3->Cells[6][0] = " Сумма";
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{

SaveDialog1->FileName="prod";
TProd n;
if (SaveDialog1->Execute())
{
ofstream f(SaveDialog1->FileName.c_str(), ios_base::out | ios_base::binary);
int r = StringGrid1->RowCount;
f.write((char*)&r,sizeof(int));
for (int i=1; i<=StringGrid1->RowCount-2; i++)
{
n.kod = StrToInt(StringGrid1->Cells[0][i].c_str());
strcpy(n.naim ,StringGrid1->Cells[1][i].c_str());
n.kol = StrToInt(StringGrid1->Cells[2][i].c_str());
//strcpy(n.ed  ,StringGrid1->Cells[3][i].c_str());
n.price =StrToFloat(StringGrid1->Cells[3][i].c_str());
f.write((char*)&n,sizeof(TProd));
}
f.close();
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
TProd n;
OpenDialog1->FileName="prod";
if (OpenDialog1->Execute())
{
char str[50];

ifstream f2(OpenDialog1->FileName.c_str(), ios_base::binary);
int n1;
f2.read((char*)&n1,sizeof(int));
StringGrid1->RowCount=n1;
for (int i=1; i<=StringGrid1->RowCount-2; i++)
{
f2.read((char*)&n,sizeof(TProd));
StringGrid1->Cells[0][i] = IntToStr(n.kod);
StringGrid1->Cells[1][i] = n.naim;
StringGrid1->Cells[2][i] = IntToStr(n.kol);
//StringGrid1->Cells[3][i] = n.ed;
StringGrid1->Cells[3][i] = FloatToStr(n.price);
}
f2.close();
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button12Click(TObject *Sender)
{
Form1->Enabled=false;
Form5->Show();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button6Click(TObject *Sender)
{
Form1->Enabled=false;
Form3->Show();
}
//---------------------------------------------------------------------------


void __fastcall TForm1::Button13Click(TObject *Sender)
{
Form1->Enabled=false;
Form4->Show();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)
{
TContr n;
OpenDialog1->FileName="contr";
if (OpenDialog1->Execute())
{
ifstream f2(OpenDialog1->FileName.c_str(), ios_base::binary);
int n1;
f2.read((char*)&n1,sizeof(int));
StringGrid2->RowCount=n1;
for (int i=1; i<=StringGrid2->RowCount-2; i++)
{
f2.read((char*)&n,sizeof(TContr));
StringGrid2->Cells[0][i] = IntToStr(n.kod);
StringGrid2->Cells[1][i] = n.naim;
StringGrid2->Cells[2][i] = n.address;
StringGrid2->Cells[3][i] = n.telefon;
}
f2.close();
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)
{
SaveDialog1->FileName="contr";
TContr n;
if (SaveDialog1->Execute())
{
ofstream f(SaveDialog1->FileName.c_str(), ios_base::out | ios_base::binary);
int r = StringGrid2->RowCount;
f.write((char*)&r,sizeof(int));
for (int i=1; i<=StringGrid2->RowCount-2; i++)
{
n.kod = StrToInt(StringGrid2->Cells[0][i].c_str());
strcpy(n.naim ,StringGrid2->Cells[1][i].c_str());
strcpy(n.address  ,StringGrid2->Cells[2][i].c_str());
strcpy(n.telefon  ,StringGrid2->Cells[3][i].c_str());

f.write((char*)&n,sizeof(TContr));
}
f.close();
}
}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button9Click(TObject *Sender)
{
Form1->Enabled=false;
Form6->Show();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button14Click(TObject *Sender)
{
Form1->Enabled=false;
Form7->Show();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button8Click(TObject *Sender)
{
SaveDialog1->FileName="zakaz";
TZakaz n;
if (SaveDialog1->Execute())
{
ofstream f(SaveDialog1->FileName.c_str(), ios_base::out | ios_base::binary);
int r = StringGrid3->RowCount;
f.write((char*)&r,sizeof(int));
for (int i=1; i<=StringGrid3->RowCount-2; i++)
{
n.kod = StrToInt(StringGrid3->Cells[0][i].c_str());
strcpy(n.data ,  StringGrid3->Cells[1][i].c_str());
strcpy(n.kontr ,StringGrid3->Cells[2][i].c_str());
strcpy(n.tovar  ,  StringGrid3->Cells[3][i].c_str());
n.kol =StrToInt(StringGrid3->Cells[4][i].c_str());
strcpy(n.ed,	 StringGrid3->Cells[5][i].c_str());
n.summa =StrToFloat(StringGrid3->Cells[5][i].c_str());
f.write((char*)&n,sizeof(TZakaz));
}
f.close();
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button7Click(TObject *Sender)
{
TZakaz n;
OpenDialog1->FileName="zakaz";
if (OpenDialog1->Execute())
{
ifstream f2(OpenDialog1->FileName.c_str(), ios_base::binary);
int n1;
f2.read((char*)&n1,sizeof(int));
StringGrid3->RowCount=n1;
for (int i=1; i<=StringGrid3->RowCount-2; i++)
{
f2.read((char*)&n,sizeof(TZakaz));

StringGrid3->Cells[0][i] = IntToStr(n.kod);
StringGrid3->Cells[1][i] = n.data;
StringGrid3->Cells[2][i] = n.kontr;
StringGrid3->Cells[3][i] = n.tovar;
StringGrid3->Cells[4][i] = IntToStr(n.kol);
//StringGrid3->Cells[5][i] = n.ed;
StringGrid3->Cells[5][i] = FloatToStr(n.summa);
}
f2.close();
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button10Click(TObject *Sender)
{
Form1->Enabled=false;
Form8->Show();
}
//---------------------------------------------------------------------------
Из за чего выдает ошибку, как на скрине, и как исправить её, заранее очень благодарен!
 
E

European

Ошибка из-за того, что переменной типа float присваивается строковое значение. Где конкретно это происходит разберись в отладке, т.к. разбираться в простыне твоего кода нет желания.

Да, и ещё, ты еще больше скриншот прилепить не смог? Очень интересно смотреть на твоего Касперского и Асю
 
Мы в соцсетях:

Обучение наступательной кибербезопасности в игровой форме. Начать игру!