### CODE doesnt work, int error...

So i did a task to improve my programming a bit but obviously my code has problems after almost finish the task and testing it out it gives me this error and i have no clue how to fix IT.

Cannot convert int * to int

The error is where "int temp" is.

 ``1234567891011121314151617181920212223242526272829`` ``````#include #include #include #include int main () { randomize(); int a[50][50]; int i,j, n, m; cout<<"Input N : "; cin>>n; cout<<"Input M: "; cin>>m; for(i=0; i a[j]) { int temp = a[j]; a[j-1] = a[j]; a[j] = temp; } getch(); }``````

any idea?
Last edited on
a[j] is a pointer to an int.
temp is an int.

They're completely different things. You can't set temp, an int, to the same value as an int pointer.

What are you trying to do there?
bubble sort algorithm

The task was to get random numbers in order using bubble sort algorithm.
No no, I mean at that line, what int value are you trying to read? What is this:
`int temp = a[j];`
trying to do?

Did you mean something like
`int temp = a[i][j];` ?
Saw the mistake, thanks

 ``123456789101112131415161718192021222324252627282930`` ``````#include #include #include #include void main () { randomize(); int a[50][50]; int i,j, n, m; int temp; cout<<"Input N: "; cin>>n; cout<<"Input M: "; cin>>m; for(i=0; i a[j]) { temp = a[i][j]; a[i][j]= a[i][j-1]; a[i][j-1] = temp; } getch(); }``````

figured out why temp wasnt working, now how do i output the result?

just like this :
 ``123`` ``````a[i][j-1] = temp; cout<

?
Last edited on
Topic archived. No new replies allowed.