lundi 4 mars 2019

stringword=""; what does it do and why for loop is starting from ; not from any integer value? [duplicate]

This question already has an answer here:

In this question why the for loop is starting from ; if the for loop is starting from ; what does it mean???and also what is the meaning of string word="";?

string word = ""; 
for (; i < str.length(); i++) { 

    if (str[i] != ' ') 
        word += str[i]; 
    else { 
        reverse(word.begin(), word.end()); 
        cout << word << " "; 
        word = ""; 
    } 
}

Aucun commentaire:

Enregistrer un commentaire