Hey, here are two codes and with one slight difference they do different things
CODE 1
#include<iostream>
using namespace std;
int main()
{
char array[2];
int i=0;
while (i<2)
{
cin>>array[i];
i++;
}
cout<<array[0]<<' '<<array[1];
}
EXAMPLE OUTPUT:
two words
t w
CODE 2
#include<iostream>
using namespace std;
int main()
{
char array[2][100];
int i=0;
while (i<2)
{
cin>>array[i];
i++;
}
cout<<array[0]<<' '<<array[1];
}
EXAMPLE OUTPUT:
two words
two words
How is that occurring, by adding an extra dimension to array it takes both words. What is going on....lol
Thanks!