I am just reviewing C++ and I don't know why 3 and 5 are the only working option. I already converted it to if-else statement but still the same issue. Below is the code:
#include <iostream>
using namespace std;
int main()
{
    char c, s[50] = {'\0'};
    int num;
    cout << "Select cin method:" << endl;
    cout << "1. cin.get(c);" << endl;
    cout << "2. cin.get(s, 10);" << endl;
    cout << "3. cin.get(s, 10, '*');" << endl;
    cout << "4. cin.getline(s, 10);" << endl;
    cout << "5. cin.read(s, 10);" << endl;
    cout << "Select: " << flush;
    cin >> num;
    switch (num) {
        case 1:
            cin.get(c); //  cin >> c;
            break;
        case 2:
            cin.get(s, 10); //  cin >> s; max length 10, '\n' as string terminator
            break;
        case 3:
            cin.get(s, 10, '*');    //  cin >> s; max length 10, '*' as string terminator
            break;
        case 4:
            cin.getline(s, 10);     //  cin >> s; max length 10, '\n' as string terminator
            break;
        case 5:
            cin.read(s, 10);        //  cin >> s; max length 10, records '\n'
            break;
        default:
            break;
    }
    if (num == 1)
        cout.put(c);                //  cout << s;
    if (num >= 2 && num <= 5)
        cout.write(s, 15);          //  cout << s; max length 15
}
Whenever I input 1/2/4 for num, it just bypasses the switch and else-if statements. I already tried checking what num is getting by "cout << num" and the value it gets is correct. I don't receive any error message either. Below is the sample of what I am getting:
Select cin method: 
1. cin.get(c); 
2. cin.get(s, 10); 
3. cin.get(s, 10, '*'); 
4. cin.getline(s, 10); 
5. cin.read(s, 10); 
Select: 1 
-------------------------------- 
Process exited after 1.676 seconds with return value 0 Press any key to continue
 
     
    