I am making a program to decode a given message by using a specified key! I m trying to come up with a my own way and it requires me to create several arrays! To check if the input was being displayed correctly(or stored properly) i m trying to display it but it somehow comes incorrect always when i have all the arrays declared when i declare only the one which i want to see ,for example only mes then it works perfectly fine! Is this some kind of overflow situation? should i use dynamic allocation?
int main() {
int t;
cin>>t;
char key[7],d[26],k[7],o[255],mes[255];
while(t--){ //loop doesn't
cin>>key;
cout<<key<<endl;
cin.getline(mes,255);
cout<<mes;
//rest of the code
}
return 0;
}
**
for input: 1
key
mess mess mess mess
output expectation is
key
mess mess mess mess
but actual outcome is
key
mess
mess mess mess
**
also the loop does not work!