在C++ BUILDER中使用STL::string的问题
#include <vcl.h>
#include <string>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
bool m_stop;
std::string f;
//string f;
f.append(0,2);
f[0]=1;
f[1]=3;
//f="cd";
//char f[2]={1,3};
//char f=2;
//string s;
std::string s;
s.append(0,5);
s[0]=1;
s[1]=2;
s[2]=1;
s[3]=3;
s[4]=1;
//s="abcde";
unsigned int pp=0;
pp=s.find(f);
m_stop=false;
}
很简单的东西,在一个std::string中查找指定的内容,这段代码在VC是没有问题的,但是在C++ BUILDER下,查找结果始终是:找不到,也就是返回 npos。。。
如果把字符串中的内容全部换成字符:也就是类似于“abcdef”这种,倒是能正常工作。。但我换成数字怎么就不行呢。。。
真是活久见啊。。。受不了了,找了半天也找不到原因
IDE是 10.2
照说C++ BUILDER对STL的支持应该是很好的呀。。。怎么会这样。。。
...全文



