mardi 28 avril 2020

Is a for-loop or iterator a faster way to traverse a string?

I have a string.

std::string strLine;

I can traverse the string chars using a if loop

for (int i = 0; strLine[i]; i++)

Another way i can do is using string iterator

string::iterator it;
for (it = strLine.begin(); it < strLine.end(); it++) 

Which is a faster and flexible way to iterate ?

Aucun commentaire:

Enregistrer un commentaire