Heyo, basically I was writing this simple function to ask you how many cars you have, inputing the amount in the array, and assigning the names of the cars to the array aswell. Also made a for loop to make display it and it says it was not declared in the scope and I just can't figure it out why it says this. Can someone help me out?
error: project2.cpp:13:16: error: 'cars' was not declared in this scope
13 | cin >> cars[i];
| ^~~~
project2.cpp:17:17: error: 'cars' was not declared in this scope
17 | cout << cars[i];
#include <iostream>
#include <string>
void display(){
int amount;
cout << "Car amount: ";
cin >> amount;
string cars[amount];
for(int i=0; i<amount; i++){
cout << "Enter " << i << " car name:";
cin >> cars[i];
'\n';
}
for(int i=0; i<amount; i++){
cout << cars[i];
}
}
using namespace std;
int main()
{
display();
return 0;
}