I am trying to create an array of size 5, and take input to fill each index, then print out each input at each index. What I am getting is the array size to be multiples of 4. So when I input 5 as the size I get 20 instead of 5. What am I missing here?
#include <iostream>
using namespace std;
int main() {
int userInput[5];
cout << sizeof(userInput);
// take input to fill array
for (int i = 0; i < sizeof(userInput); i++) {
cin >> userInput[i];
}
// print the array contents
for (int i = 0; i < sizeof(userInput); i++) {
cout << userInput[i]
}
}