How can I use 4 different ways of input?

36 views Asked by At

I want to input 4 different values(double, char, string, char[]) and print each values.

#include<iostream>
#include<string>
using namespace std;
int main() {
    double number; char a; string str; char st[10];

    cout << "Put any number : ";
    cin >> number;
    cout << "Put any char : ";
    cin >> a;
    cout << "Put any string : ";
    getline(cin, str);
    cout << "Put any string : ";
    cin.getline(st, 100);
    cout << number << " " << a << " " << str << " " << st;
    return 0;
}

In this case, I can't input 'str'. If I put a value in 'a', it moves right away to put a value in 'st'.

I want know what I have to modify.

0

There are 0 answers