Pointer to Array Problem, Urgent Help plz
Hi, Im using pointer to display values of an array but its output is not correct example 23424,0, -323423 etc... whats the problem with my code:
Code:
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
int arr[10][10],rows,cols;
int* ptr;
printf("\nNo. of Rows: ");
scanf("%d", &rows);
printf("\nNo. of Cols: ");
scanf("%d", &cols);
//storing values in array
for(int i=0; i<rows; i++)
for(int j=0; j<cols; j++)
{
printf("\nEnter element Row %d Column %d: ", i,j);
scanf("%d", arr[i][j]);
}
//displaying values using pointers
for(i=0; i<rows; i++)
for(j=0; j<cols; j++)
{
ptr=&arr[i][j];
printf("\n%d", *ptr);
}
getch();
}