简体   繁体   中英

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

I want to store the value of std::string::iterator into a char * . How can I do it ? eg

char* t_agent_val_c;

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

You can do:

t_agent_val_c = &*itr;

And *itr != std::string::npos is incorrect, should be itr != my_string.end() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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