'Proper way to pull ASCII characters from a number [closed]

I have created a small program to put whatever characters specified into ASCII and this works as expected.

The problem I am having is when trying to pull the characters from the ASCII number representation.

    int a1, a2, a3, a4, a5;
    cout << "Enter your ASCII Message: ";
    cin >> a1, a2, a3, a4, a5;
    cout << "Unciphered Message: "  << char(a1) <<  char(a2) << char(a3) << char(a4) << char(a5) << endl;

I expected the above code to pull the proper character depending on the number specified, but it seems to only recognise the first character.



Solution 1:[1]

I was improperly passing variables to cin. The line

cin >> a1, a2, a3, a4, a5;

should be replaced with:

cin >> a1 >> a2 >> a3 >> a4 >> a5;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andreas Wenzel