The char array in the following can take in two values as is shown in the OUTPUT. There were three inputs but it only accepted two. But shouldn't it only accept one character or value because it also needs room to accommodate null character? Please guide me. Thanks.
OUTPUTCode:#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
const int C = 2;
char array[C];
cout << "enter values for the array: ";
cin >> array;
for (int i=0; i<C; i++)
{
cout << array[i];
}
cout << endl;
system("pause");
return 0;
}
Code:enter values for the array: abc
ab
Press any key to continue . . .