I'm currently learning C++17 from the book "C++17 from beginner to professional". In the control statements part of the book, I was told that one can declare variables to be used in an if statement inside the if round braces of the if statement i.e something like this
if(int a {2}, int b {2}; a<b) {cout << a << endl;}
when I tried that using Code::Blocks it told me it was expecting a ')' before the ';' token. However in the book, there was nothing as such.
On VisualStudio it was telling me
"language feature 'init-statements in if/switch' requires C++ project compiler flag '/std:C++17'**
In particular I was trying to run the code below.
char input;
cin >> input;
if (auto lower{ static_cast<char>(std::tolower(input)) }; lower >= 'a' && lower <= 'z') {
std::cout << "You've entered the letter '" << lower << '\'' << std::endl;
}