I am trying to copy the column, from bottom to top element,to the row , but it does not work. Plase help

#include <stdio.h>
int main () {
int Image1[3][3]={{1,2,3},{4,5,6},{7,8,9}};
int Image2[3][3];

int i= 3; 
int j =3;
int k =0 ;
int l;


    while ( k <= 0){
        i=0;
        j=3;
        while (i < 3){
            Image1[i][k]= Image2[j][k];
            j--; 
            i++;
       }
    k++;
       }    



for (k =0 ; k < 3; k++){
      for (l = 0 ;l< 3; l++){
         fprintf(stdout, "%d    ", Image2[k][l]);
    }
    printf("\n");
} 
    return (0);
}

line 12 while ( k <= 0)
This condition is only met when k = 0.

line 14 j=3;
This is out of bounds for your matrix, valid values are 0 to 2 inclusive.

line 16 Image1[i][k]= Image2[j][k];
This is the wrong way around. You're just copying memory junk from Image2 to Image1.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.