I am writing a program and the errors are all for the lines in which I place a variable in the brackets of i (lines 22, 30, 37, 44) They say that subscript requires array or pointer type and that expression must have the pointer-to-object type. How can I fix this? My program is below. And yes, I have indentation just pasting it in removed it.
#include <iostream>
using namespace std;
int main(){
const int MAX = 25;
int data[MAX];
int count = 0;
int input;
do{
cout << "Enter a number (-1 to stop): ";
cin >> input;
if (input != -1 && input >= 0){
data[count ++] = input;
}
if (input < -1){
cout << "Invalid input. This will not be included in your values." << endl;
}
} while (input != -1 && count < MAX);
for(int i = 0; i < count; i++){
cout << input[i] << ', ';
}
cout << endl;
int output[25];
int count2 = 1;
int duplicate = 0;
I was trying to find a way to print out the input and to use it when comparing to output so that is what I tried (couldn't really follow my programming book). I tried just printing input but it only prints -1 since that is what is entered in the end. Is there a way to print it so each value gets printed?