jeudi 21 janvier 2021

Is there a C++ equivalent for multiple assignment in Python?

In python how you can assign multiple values to different variables by separating the values with a comma. e.g., a, b = 10, 20 Is there a c++ equivalent?

I was sorting through a string and I want to assign the integers found in the string to variables. While I have managed to extract an integer, I am wondering how I assign it inside the loop.

while (sObj){
    sobj >> seperateWord;
    if(sObj(seperateWord) >> integerInString){
        cout << integerInString << " ";
    }        
}

Here, instead of printing it, can i save it to different variables?

Aucun commentaire:

Enregistrer un commentaire