Coding Global Background
Coding Global

help

2 Nachrichten
2 Mitglieder
10 days ago
In Discord öffnen
T
Tense
Verified

im doing tutorial 1.5 on learn cpp.com and i have question in their example: int x{}; std::cin >> x; they input `5a` and the output is `5`. Why is the output not `50` or just `0` on their site it says that "If no characters could be extracted in step 4 above, extraction has failed. The object being extracted to is copy-assigned the value 0 (as of C++11), and any future extractions will immediately fail (until std::cin is cleared)." my understanding is of the process is that: 1. `5` is extracted successfully 2. extraction stops at the white space 3. attempts to extract `a` but fails from here it should copy-assign a value of `0`, but why not?

Antworten (2)