cout a char after a number avoiding pressing enter

guys i am doing a project and this is a problem ....i wanna to cin an array
with this form
[1;2;3;4;5]

but after i type 1 it doesn't show the ";" or "]"
i have to press enter .....
but what i want is to make them in the same line
[1;2;3;4;5]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  #include <iostream>
#include <string>

#include <math.h>
using namespace std;

int main()
{char z=';',b=']';
int arr[5];
for (int i=0;i<5;i++)
    {
        if (i==0){
        cout <<"[";
        cin>>arr[i];
    cout <<";";
    }
    
    if (i<4){
     cin>>arr[i];
     cout<<";";}
     
     
     else {
        cin>>arr[i];
        cout<<"]";
     }
    }
    cout<<endl;

cout<<endl;
 return 0;
}
Last edited on
Topic archived. No new replies allowed.