如何將string 直接assign 給AnsiString?? |
尚未結案
|
plihui
初階會員 發表:88 回覆:96 積分:41 註冊:2003-07-03 發送簡訊給我 |
|
Stallion
版主 發表:52 回覆:1600 積分:1995 註冊:2004-09-15 發送簡訊給我 |
|
plihui
初階會員 發表:88 回覆:96 積分:41 註冊:2003-07-03 發送簡訊給我 |
|
Stallion
版主 發表:52 回覆:1600 積分:1995 註冊:2004-09-15 發送簡訊給我 |
|
haman
中階會員 發表:46 回覆:137 積分:56 註冊:2005-03-10 發送簡訊給我 |
你指的是help中的
A string is basicallya sequence of characters that can be indexed. In fact, although a string is not declared as a subclass of vector, almost all the vector operators discussed in the vector data abstraction (and subsequent topics) can be applied to string values. Indeed, a string qualifies as a sequence container type. However, a string is also a much more abstract quantity. In addition to simple vector operators, the string datatype provides a number of useful and powerful high level operations. In the Standard C++ Library, a string is actually a template class, named basic_string. The template argument represents the type of character that will be held by the string container. By defining strings in this fashion, the Standard C++ Library not only provides facilities for manipulating sequences of normal 8-bit ASCII characters, but also for manipulating other types of character-like sequences, such as 16-bit wide characters. The datatypes string and wstring (for wide string) are simply typedefs of basic_string, defined as follows: typedef basic_string
|
zcecil
初階會員 發表:0 回覆:28 積分:45 註冊:2003-06-27 發送簡訊給我 |
|
haman
中階會員 發表:46 回覆:137 積分:56 註冊:2005-03-10 發送簡訊給我 |
剛剛試了一下,string會有錯,結果跑去翻string(在.\Borland\CBuilder6\Include\Vcl下) 下面是string的內容...
/* * Copyright (c) 1997-1999 * Silicon Graphics Computer Systems, Inc. * * Copyright (c) 1999 * Boris Fomitchev * * This material is provided "as is", with absolutely no warranty expressed * or implied. Any use is at your own risk. * * Permission to use or copy this software for any purpose is hereby granted * without fee, provided the above notices are retained on all copies. * Permission to modify the code and to distribute modified code is granted, * provided the above notices are retained, and a notice that the code was * modified is included with the above copyright notice. * */ #ifndef _STLP_STRING # define _STLP_STRING # ifndef _STLP_OUTERMOST_HEADER_IDbasic_string # define _STLP_OUTERMOST_HEADER_ID 0x68 # include裡面似乎沒有定義"string"這個資料型態或類別 你確定你的string i="abcd"的string是用#include <string>出來的? zcecil大大說的.c_str是在AnsiString或String中才有的 因為我找不到"string"這個資料型態或類別,所以也不知道"string"下有沒有c_str可以用 |
haman
中階會員 發表:46 回覆:137 積分:56 註冊:2005-03-10 發送簡訊給我 |
不小心按到了@@"
如果你要把const string設給AnsiString的話可以直接用下面這個方式
char *i = "abcd"; String s = i;如果你要把AnsiString設給char string的話可以直接用下面這個方式 #includePS..剛剛查了一下help,只有AnsiString中有c_str()可以用 當然,如果有其他東西繼承了AnsiString的話我就不清楚了.. |
zcecil
初階會員 發表:0 回覆:28 積分:45 註冊:2003-06-27 發送簡訊給我 |
#include < string > 的定義在 Include\stl 下的 _string.h 裡(請注意看stlport\string, 它其實是有 include stl\_string.h 的) 可以正常編過的程式如下:
#include < string >
using namespace std; int main()
{
string a="123";
AnsiString b = a.c_str();
} 請確定你的程式裡沒有漏了 using namespace std; 順帶一提
String 是 delphi 的type, 在 BCB 裡對應的是 AnsiString.
string 和 String 是不同的兩回事. String(AnsiString) 是BCB附的class, string則是 C 標準程式庫裡的東西. 發表人 - zcecil 於 2005/09/21 19:05:49 發表人 - zcecil 於 2005/09/21 19:07:09
|
haman
中階會員 發表:46 回覆:137 積分:56 註冊:2005-03-10 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |