PLEASE HELP

i have a project due in two days and im having an issue with my array, i need to have the user enter the data into the array, and that part works perfectly, but when i try to pull out an element and adress it it gives me "invalid types "int[int]" for array subscript cout << j[0];


#include <iostream>
#include <string>

using namespace std;

int side1();

int main()
{
int side;

cout << "enter the number of sides";

cin >> side;

cout << side;

int i = side;

string* str = new string[i];
string input;

for(int j = 0 ; j< i ; j++) {

cout << "please enter the weight for side:" << j << "\n";

cin >> input;
str[j] = input;
}

for(int j = 0; j < i ; j++)
{
cout << "element:" << j << "=" << str[j];
cout << j[0];
}

return 0;
}
The variable j is not an array. What is the code suppose to do?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <string>

using namespace std;

int side1();

int main()
{
	int side;

	cout << "enter the number of sides";

	cin >> side;

	cout << side;

	int i = side;

	string* str = new string[i];
	string input;

	for (int j = 0; j < i; j++) {

		cout << "please enter the weight for side:" << j << "\n";

		cin >> input;
		str[j] = input;
	}

	for (int j = 0; j < i; j++)
	{
		cout << "element:" << j << "=" << str[j];
		cout << j[0];
	}

	return 0;
}
Topic archived. No new replies allowed.