Array Pointer Error

I am building a small program for fun currently. The first part of the program builds an array off of user size input and then randomly generates numbers to fill the array. After that it goes through the entire array to find the largest number. This is a very simple program so far and catching the error should be easy for someone. Here is my code so far:

#include <iostream>
#include <ctime> //Rand generator
#include <cstdlib>
using namespace std;

void generate();

main(){
generate();

return 0;
}

void generate(){
int x, y;
int temp=0;
cout << "Enter Rows: ";
cin >> x;
cout << endl;
cout << "Enter Columns: ";
cin >> y;

/* Initializes and fills array */
int array[x][y];
srand(time(NULL));

for(int i =0; i < x; i++){
for(int j=0; j < y; j++){
array[i][j]= rand() % 100 + 0;
}
}

for (int i=0; i < x; i++){
for(int j=0; j < y; j++){
cout << array[i][j]<< "\t";
}
cout << endl;
}

for (int i=0; i < x; i++){
for(int j=0; j < y; j++){
if(array[i] > temp)
array[i]= temp;
}
}
cout << "Greatest number is: " << temp << endl;
}

When compiling I get the errors:
generator.cpp:51: error: ISO C++ forbids comparison between pointer and integer

generator.cpp:52: error: incompatible types in assignment of ‘int’ to ‘int [(((long unsigned int)(((long int)y) + -0x00000000000000001)) + 1)]’
1) Line int array[x][y]; is not technically legal, as x and y are not compile time constants. Your compiler allows it due to extension enabled, by it will not work for everyone.

2) if(array[i] > temp) array is a two dimnsional array, or array of arrays. So when you provide only one index, you are selectind one subarray from large array of arrays. Array != int. Maybe you want to write array[i][j]?
Still having troubles with this. I am ok with the part 1 of your suggestion because this program will be running on my machine only and will use the proper compiler.

As for part two I tries a few things but still nothing has worked or it points to the address of the array and not the value. Any syntax suggestions?
As I said: use array[i][j]. And notice this line:
array[i]= temp; Aside from [i]/[i][j] error, what do you think this line is doing?
Topic archived. No new replies allowed.