here is a code to read an array of characters until user press CTRL+C
void read_ctrl_z(char *x){
int i = 0;
while (true) {
x[i++] = getch();
if(x[i-1] == 26) {
x[i-1] = '\0';
cout<<endl;
break;
}else{
cout<<x[i-1];
}
}
}