我發現試圖幫助我的唯一問題是這一個C++: splitting a string into an array。 我是新來的c + +,我需要有一個字符串數組,共同擁有這些字,我有這個字。如何創建一個字符串數組,用於分隔由「」分隔的單詞的字符? C++
下面是代碼:
s3eFile* file = s3eFileOpen("chatTest/restrict_words.txt","rb");
int len = s3eFileGetSize(file);
char* temp = new char[len];
if (file!=NULL)
{
s3eFileRead(temp,len,1, file);
s3eFileClose(file);
}
所以我需要讓這個溫度在轉向一個數組,所以我可以使用它? 有一種方法?
由於你正在使用新的,爲什麼不使用矢量而不是普通的數組? – ebasconp
vector?我想它確定我只需要知道如何去做 –
user3120770
使用'std :: string :: find'或它的一個親戚。另見'std :: string :: substr'。 –