繁体   English   中英

有什么方法可以将std :: string :: iterator的值存储在C ++中的char *中?

[英]Is there any way to store the value of std::string::iterator in a char * in C++?

我想将std::string::iterator的值存储到char * 我该怎么做 ? 例如

char* t_agent_val_c;

while (*itr != std::string::npos && *itr != '}')
{
    t_agent_val_c = itr.c_str();
    t_agent_val_c++;
    itr++;
}

你可以做:

t_agent_val_c = &*itr;

并且*itr != std::string::npos不正确,应该是itr != my_string.end()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM