C++ builder中copy()函数咋未定义

huazi9999 2018-03-13 10:05:40
while (length(tmp1)>3)
{
tmp2=copy(tmp1,1,3);
delete(tmp1,1,3);
MID=MID+Chr(35+StrToInt(tmp2)*26/999)+tmp2;

}

提示length(),copy()函数未定义;
下面是我的头函数:
#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include<dstring.h>
#include <iostream>
#include<vector>
#include<deque>
#include<algorithm>
...全文
721 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
huazi9999 2018-03-13
  • 打赏
  • 举报
回复
谢大神,按你说的试了下,完美解决。
hongss 2018-03-13
  • 打赏
  • 举报
回复
以上代码,在Win7 + BCB6, 或者 XE2下编译通过 BCB6
//---------------------------------------------------------------------------

#include <vcl.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::Btn_1Click(TObject *Sender)
{
AnsiString tmp1, tmp2, MID;

while (tmp1.Length()>3)
{
   tmp2= tmp1.SubString(1,3);
   tmp1.Delete(1,3);
   MID=MID+char(35+StrToInt(tmp2)*26/999)+tmp2;
}

}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
        TButton *Btn_1;
        void __fastcall Btn_1Click(TObject *Sender);
private:	// User declarations
public:		// User declarations
        __fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
huazi9999 2018-03-13
  • 打赏
  • 举报
回复
我用的BCB ,我试了一下还是不行。 Call to undefined function 'length' E2268 Call to undefined function 'SubString'
hongss 2018-03-13
  • 打赏
  • 举报
回复
BCB和Delphi用法不一样 试试这个

while (tmp1.Length()>3)
{
   tmp2= tmp1.SubString(1,3);
   tmp1.Delete(1,3);
   MID=MID+char(35+StrToInt(tmp2)*26/999)+tmp2;
}

1,221

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧