string Sound::Read_Data(string delimiter, string prefix) { bool more=true; string tmp; string data; while(((getline(m_read_file, tmp))||(true==more))) { if(m_read_file.eof()) { more = false; m_read_file.clear(); m_read_file.seekg(0, ios_base::beg); getline(m_read_file, tmp); } data=deCaps(tmp.substr(0, tmp.find(delimiter))); data=delSpace(data); prefix=deCaps(prefix); if(tmp[0]=='/') { } else if(data==prefix) { data=tmp.substr((tmp.find(delimiter)+1), tmp.size()); data=delSpace(data); tmp=""; return data; } } if((false==more) && m_read_file.eof()) { data = "none"; } return data; }
int main() { const char* str = "aaaaaaabbbbbbbccccccddassss111111"; char output[100]; strcpy(output, str); printf("%s\n", delAdjacentRepeat(output)); char cs[] = " 中文 bbbbbb \nX\n 汉字 测试 "; printf("%s\n", cs); printf("%s\n", delSpace(cs)); printf("%d\n", strlen(cs)); }