私は自分自身を、文字列をとり、特定の文字の後にその言葉を与えるプログラムにしようとしています。したがって、たとえば:特定の文字の後に単語を取得しますか?
String theString = "hello \t world"; // or "borld \t bello";
タブの後、私は「世界」だけでなく「こんにちは」を望んでいます。これはなんらかの理由で私に衝突し続けます。
size_t delimiter = theString.find_last_of('\t');
char *test;
if (theString.find("hello") != string::npos) {
strcpy(test, theString.substr(delimiter + 1).c_str());
else if (theString.find("borld") != string::npos) {
strcpy(test, theString.substr(delimiter + 1).c_str());
}
cout << test;
_これは何らかの理由で私にクラッシュしてしまいます。_もちろん、 'char * test;'のためのスペースは決して割り当てられません。 –