M
M
m_shpakov2016-03-16 17:32:36
C++ / C#
m_shpakov, 2016-03-16 17:32:36

How to iterate character-by-character string variable c++?

In general, a sentence is written to the string variable. It is necessary to loop through it character by character for comparison. How to do it, preferably without a char variable?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Martyanov, 2016-03-16
@m_shpakov

str[0] for example does not suit you?

A
Alexander Movchan, 2016-03-16
@Alexander1705

string str = "Hello, world!";

for (auto c : str)
{
    do_something(c);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question