#include<stdio.h>
void storeTables(int arr[][10] , int n ,int number);
int main() {
int tables[2][10];
storeTables(&tables[1],1,2);
storeTables(tables,0,3);
for(int i = 0 ; i<10 ; i++){
printf("%d \t",(tables[0][i]));
}
printf("\n");
for(int i = 0 ; i<10 ; i++){
printf("%d \t",tables[1][i]);
}
return 0 ;
}
void storeTables(int arr[][10] , int n ,int number){
for(int i = 0 ; i<10 ; i++){
arr[n][i] = number * (i+1) ;
}
}
look at this code . in storeTable when i write storeTables(tables,0,2); it gives desired result . if i write storeTables(&tables[0],0,2); it still gives desired result . but when i write storeTables(&tables[1],1,2); it gives random addresses as a result . which is probablly wrong . passing &tables[1] just means passing 2nd row of 2d array . what's the problem in doing so . why the answer is coming wrong ?
i tried asking to chatGPT but its not understanding the errror . i am expecting a table of 2 and 3 as a result . if i pass pointer to 2d array i'll get the result . if i pass pointer to an array of 10 integers . i get the result but i pass pointer to 2nd array of 10 integers first my result becomes wrong start printing addresses . also things like &tables[0][1] or tables + 1 will not going to work as i have tried them all , also i have tried writing int(*arr)[10] instead of int arr[][10] in the storeTables function but i don't want use pointer do it by using only int arr[][10] function . please help me .`