Форум программистов, компьютерный форум, киберфорум
C++ Builder
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.67/6: Рейтинг темы: голосов - 6, средняя оценка - 4.67
0 / 0 / 0
Регистрация: 21.03.2019
Сообщений: 12
Builder 6

Код в c++ builder 6

20.06.2019, 17:11. Показов 1215. Ответов 5
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Помогите исправить код.

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
//---------------------------------------------------------------------------
 
#include <vcl.h>
#pragma hdrstop
 
#include "Unit1.h"
//---------------------------------------------------------------------------
#include <stdio.h>
#include <jpeg.hpp>
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int f;
int level[4];
AnsiString mes[4];
TVopros Vopros;
int otv;
int right = 0;
int GetInt(int f);
int Getstring(int f, AnsiString *st);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
   : TForm(Owner)
{
int i;
int left = 10;
 
for (i = 0; i < 4; i++)
  {
RadioButton[i] = new TRadioButton(Form1);
RadioButton[i]->Parent = Form1;
RadioButton[i]->Left = left;
RadioButton[i]->Width=Form1->ClientWidth - left -20;
RadioButton[i]->Visible = false;
RadioButton[i]->Checked = false;
 
RadioButton[i]->OnClick = RadioButtonClick;
 }
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate(TObject *Sender)
{
AnsiString st;
int n = ParamCount();
if ( n< 1)
{
Label1->Font->Style = TFontStyles()<< fsBold;
Label1->Caption = ("В командной строке надо задать имя файла текста");
Button1->Tag =2;
return;
}
 
f = FileOpen(ParamStr(1), fmOpenRead);
if ( f == -1)
{
Label1->Font->Style = TFontStyles()<< fsBold;
Label1->Caption = "Ошибка доступа к файлу текста" + ParamStr(1);
Button1->Tag = 2;
return;
}
GetString(f, &st);
Form1->Caption = st;
 
GetString(f, &st);
Label1->Width = Form1->ClientWidth - Label1->Left - 20;
Label1->Caption = st;
Label1->AutoSize = true;
 
for (int i+0; i<4; i++)
{
   lavel[i] = GetInt(f);
   GetString(f, %mes[i]);
   }
}
 
bool GetVopros(TVopros *v)
{
AnsiString st;
int p;
if (GetString(f, &(v->Vopr)) !=0);
{
v->nOtv = GetInt(f);
v->rOtv = GetInt(f);
p = GetInt(f);
 
if (p)
GetString(f,&(v->Img));
else v->Img = "";
 
for ( int i = 0; i < v->nOtv ; i++)
{
GetString (f,&(v->Otv[i]));
}
retirn true;
}
else return false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ShowVopos(TVopros v)
{
int top;
int i;
 
Label1->Width = ClientWidth - Label1->Left -20;
Label1->Caption = v.Vopr;
Label1->Autosize = true;
 
if (v.Img != "")
{
int RegHight = Button1->Top
- (Lebel1->Top + Label1->Height +10)
- (RadioButton[1]->Height +10) * v.nOtv;
 
Image1->Top = Label1->Top + Label1->Height 10;
 
Imagel->Visible = false;
Imagel->AutoSize = true;
Imagel->Picture->LoadFromFile(v. Img);
if (Imagel->Height > RegHeight)
{
Imagel->AutoSize = false;
Imagel->Height = RegHeight;
Imagel->Proportional = true;
}
Imagel->Visible = true;
else
top = Labell->Top + Labell->Height + 10;
for (i = 0; i < v.nOtv; i++)
{
RadioButton[i]->Top = top;
RadioButton[i]->Caption = v.otvli}:
RadioButton[i]->Visible = true;
RadioButton[i]->Checked = falee;
top += 20;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::RadioButtonClick(TObject *Sender)
{
int i =0;
while ( ! RadiButton[i]->Checked)
i++;
otv = i+1;
Button1->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::EraseVopros(void)
{
Image1->Visible = false;
 
for (inti = 0; i<4; i++)
{
   RadioButton[i]->Visible = false;
   RadioButton[i]->Checked = false;
}
Button1->Enabled = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
bool ok;
 
switch (Button1->Tag)
{
case 0:
   GetVopros(&Vopros);
   ShowVopros(Vopros);
 
   Button1->Caption = "Дальше";
   Button1->Enabled = false;
   Button1->Tag = 1;
   break;
case 1:
   if ( otv == Vopros.rOtv)
   right++;
   EraseVopros();
   ok = GetVopros(&Vopros);
   if ( ok )
      ShowVopros(Vopros);
      else
      {
      FileClose(f);
      AnsiString;
      AnsiString st;
      int i;
      Form1->Caption = "Результат тестирования";
      st.printf(
      "Правильных овтетов: %i\n",right
      };
 
      i = 0;
      while (( right < level[i]) && (i<3))
      i++;
      st = st + mes[i];
       Label1->Caption = st;
 
       Button1->Caption = "OK";
       Button1->Enabled = true;
       Button1->Tag = 2;
      }
      break;
      case 2:
      Form1->Close();
      }
}
}
//---------------------------------------------------------------------------
int GetString(int f, AnsiString *st)
{
unsigned char buf[300];
unsigned char *p = buf;
 
int n;
int len = 0;
 
n= FileRead(f,p,1);
while ( n != 0)
{
if ( *p == '\r')
{
n = FileRead(f,p,1);
break;
}
len++;
p++;
n=FileRead(f,p,1);
}
*p = '\0';
if ( len !=0) st->printf("%s", buf);
return len;
}
 
int GetInt(int f)
{
char buf[20];
char *p = buf;
 
int n;
int a;
 
n = FileRead (f,p,1);
}
if (*p == '\r')
n =FileRead (f,p,1);
*p = '\0';
sscanf(buf, "%1", &a);
return a;
}

ОШИБКИ.


[C++ Error] Unit1.cpp(30): E2451 Undefined symbol 'RadioButton'
[C++ Error] Unit1.cpp(41): E2089 Identifier 'FormActivate' cannot have a type qualifier
[C++ Error] Unit1.cpp(204): E2139 Declaration missing ;
[C++ Warning] Unit1.cpp(204): W8004 'left' is assigned a value that is never used
[C++ Error] Unit1.cpp(204): E2190 Unexpected }
[C++ Error] Unit1.cpp(205): E2190 Unexpected }
[C++ Warning] Unit1.cpp(241): W8070 Function should return a value
[C++ Warning] Unit1.cpp(241): W8004 'n' is assigned a value that is never used
[C++ Error] Unit1.cpp(242): E2040 Declaration terminated incorrectly
[C++ Error] Unit1.cpp(245): E2303 Type name expected
[C++ Error] Unit1.cpp(245): E2356 Type mismatch in redeclaration of 'sscanf(const char *,const char *,...)'
[C++ Error] Unit1.cpp(245): E2063 Illegal initialization
[C++ Error] Unit1.cpp(245): E2293 ) expected
[C++ Error] Unit1.cpp(246): E2040 Declaration terminated incorrectly
[C++ Error] Unit1.cpp(247): E2190 Unexpected }
0
IT_Exp
Эксперт
34794 / 4073 / 2104
Регистрация: 17.06.2006
Сообщений: 32,602
Блог
20.06.2019, 17:11
Ответы с готовыми решениями:

Перенести код из C++ Builder 5 в C++ Builder 2009
Здравствуйте! Назрела проблема, может быть поможете. СУть в следующем - сделал прогу на 5-ом Билдере, приношу преподу показывать, а там...

Исходный код C++ Builder 6 в С++ Builder 5
Всем добрый вечер, ребята подскажите пожалуйста может кто сталкивался когда нужно исходник из 6 версии Builder'a описать в исходном коде 5...

Перенести код из VC++ в CPP Builder (код использует DLL)
Такая проблема. Есть DLL + пример её использования на Visual C++, пытаюсь этот пример перенести в Builder. Проблемы возникают в самом...

5
Супер-модератор
Эксперт Pascal/DelphiАвтор FAQ
 Аватар для volvo
33378 / 21502 / 8236
Регистрация: 22.10.2011
Сообщений: 36,899
Записей в блоге: 11
20.06.2019, 17:14
Что именно исправлять-то? В чем проблема этого кода?
0
0 / 0 / 0
Регистрация: 21.03.2019
Сообщений: 12
20.06.2019, 17:17  [ТС]
ОШИБКИ.


[C++ Error] Unit1.cpp(30): E2451 Undefined symbol 'RadioButton'
[C++ Error] Unit1.cpp(41): E2089 Identifier 'FormActivate' cannot have a type qualifier
[C++ Error] Unit1.cpp(204): E2139 Declaration missing ;
[C++ Warning] Unit1.cpp(204): W8004 'left' is assigned a value that is never used
[C++ Error] Unit1.cpp(204): E2190 Unexpected }
[C++ Error] Unit1.cpp(205): E2190 Unexpected }
[C++ Warning] Unit1.cpp(241): W8070 Function should return a value
[C++ Warning] Unit1.cpp(241): W8004 'n' is assigned a value that is never used
[C++ Error] Unit1.cpp(242): E2040 Declaration terminated incorrectly
[C++ Error] Unit1.cpp(245): E2303 Type name expected
[C++ Error] Unit1.cpp(245): E2356 Type mismatch in redeclaration of 'sscanf(const char *,const char *,...)'
[C++ Error] Unit1.cpp(245): E2063 Illegal initialization
[C++ Error] Unit1.cpp(245): E2293 ) expected
[C++ Error] Unit1.cpp(246): E2040 Declaration terminated incorrectly
[C++ Error] Unit1.cpp(247): E2190 Unexpected }
0
Супер-модератор
Эксперт Pascal/DelphiАвтор FAQ
 Аватар для volvo
33378 / 21502 / 8236
Регистрация: 22.10.2011
Сообщений: 36,899
Записей в блоге: 11
20.06.2019, 17:19
Не хватает еще *.h файла, чтобы знать, что описано в нем, а что - нет. Но на первый взгляд - просто не хватает нескольких закрывающих скобок.
0
0 / 0 / 0
Регистрация: 21.03.2019
Сообщений: 12
20.06.2019, 17:20  [ТС]
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
////---------------------------------------------------------------------------
 
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
//---------------------------------------------------------------------------
struct TVopros {
 AnsiString Vopr;
 AnsiString Img;
 AnsiString Otv[4];
 int nOtv;
 int rOtv;
 };
class TForm1 : public TForm
{
__published:    // IDE-managed Components
   TImage *Image1;
   TLabel *Label1;
   TButton *Button1;
   void __fastcall FormActivate(TObject *Sender);
   void __fastcall ShowVopos(TVopros v);
   void __fastcall RadioButtonClick(TObject *Sender);
   void __fastcall EraseVopros(void);
   void __fastcall Button1Click(TObject *Sender);
private:    // User declarations
public:     // User declarations
   __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
0
Практикантроп
 Аватар для nick42
4841 / 2726 / 534
Регистрация: 23.09.2011
Сообщений: 5,798
20.06.2019, 20:59
А где здесь RadioButton? В *.cpp-файле он остался; событие RadioButtonClick осталось; а сам компонент отсутствует в *.h - файле.
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
BasicMan
Эксперт
29316 / 5623 / 2384
Регистрация: 17.02.2009
Сообщений: 30,364
Блог
20.06.2019, 20:59
Помогаю со студенческими работами здесь

Почему данный код работает в builder 6 а в builder 10 не работает?
SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) | WS_EX_LAYERED); SetLayeredWindowAttributes(Handle, 0, 128,...

Код Qt в C++ Builder
Помогите перевести. спасибо))) edftools.cpp #include &quot;edftools.h&quot; const char cryptBytes =...

Код C++ 11 в builder 6.0
Есть такой код _triangles.erase(std::remove_if(begin(_triangles), end(_triangles), (TriangleType &amp;t){ return t.isBad; ...

Код С++ Builder 6
Плиз помогите проблема: помогаю делать курсач и возникла проблема в коде: if (FileExists (&quot;d:\\F.txt&quot;)== false) { ...

код с Visual C++ в Builder C++6
Добрый вечер! Возникли некоторые вопросы, перевести код с Visual C++ в Builder C++6. CDSRecordApp theApp; BOOL...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
6
Ответ Создать тему
Новые блоги и статьи
SDL3 для Web (WebAssembly): Обработчик клика мыши в браузере ПК и касания экрана в браузере на мобильном устройстве
8Observer8 02.02.2026
Содержание блога Для начала пошагово создадим рабочий пример для подготовки к экспериментам в браузере ПК и в браузере мобильного устройства. Потом напишем обработчик клика мыши и обработчик. . .
Философия технологии
iceja 01.02.2026
На мой взгляд у человека в технических проектах остается роль генерального директора. Все остальное нейронки делают уже лучше человека. Они не могут нести предпринимательские риски, не могут. . .
SDL3 для Web (WebAssembly): Вывод текста со шрифтом TTF с помощью SDL3_ttf
8Observer8 01.02.2026
Содержание блога В этой пошаговой инструкции создадим с нуля веб-приложение, которое выводит текст в окне браузера. Запустим на Android на локальном сервере. Загрузим Release на бесплатный. . .
SDL3 для Web (WebAssembly): Сборка C/C++ проекта из консоли
8Observer8 30.01.2026
Содержание блога Если вы откроете примеры для начинающих на официальном репозитории SDL3 в папке: examples, то вы увидите, что все примеры используют следующие четыре обязательные функции, а. . .
SDL3 для Web (WebAssembly): Установка Emscripten SDK (emsdk) и CMake для сборки C и C++ приложений в Wasm
8Observer8 30.01.2026
Содержание блога Для того чтобы скачать Emscripten SDK (emsdk) необходимо сначало скачать и уставить Git: Install for Windows. Следуйте стандартной процедуре установки Git через установщик. . . .
SDL3 для Android: Подключение Box2D v3, физика и отрисовка коллайдеров
8Observer8 29.01.2026
Содержание блога Box2D - это библиотека для 2D физики для анимаций и игр. С её помощью можно определять были ли коллизии между конкретными объектами. Версия v3 была полностью переписана на Си, в. . .
Инструменты COM: Сохранение данный из VARIANT в файл и загрузка из файла в VARIANT
bedvit 28.01.2026
Сохранение базовых типов COM и массивов (одномерных или двухмерных) любой вложенности (деревья) в файл, с возможностью выбора алгоритмов сжатия и шифрования. Часть библиотеки BedvitCOM Использованы. . .
SDL3 для Android: Загрузка PNG с альфа-каналом с помощью SDL_LoadPNG (без SDL3_image)
8Observer8 28.01.2026
Содержание блога SDL3 имеет собственные средства для загрузки и отображения PNG-файлов с альфа-каналом и базовой работы с ними. В этой инструкции используется функция SDL_LoadPNG(), которая. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru