I have an assignment that requires me to not use an array with [] at all throughout my code, read a file in a certain way, and I need a better understanding with malloc as well with pointers. The code with the [] is pretty easy for me, but pointers confuses me. I don't expect every single one of these to be answered which is fine.
For example:
/*input from datafile.dat*/
3
2
4
1 2
3 4
5 6 7 8
I understand that I need to get all that in the array which I got down. Array[2] should be 4 as
#define array 80
....
void matrices(int **A, int **B, int **C, int *m, int *n, int *p, char *str){
...
char *pa= array;
8/
p =*(pa+2) /* is 4?
...
}
As for the arrary with [] to an array with no [], if someone can help me convert this code to no [], I can take care of everything else in my program. Where x,y are the dimensions of a 2d matrix.
A[x][y] =(x*2)+ y + 1;
Lastly, I see this kind of codes for malloc, but I am confused on what it does.
if(((*A = malloc((r)*(c)*sizeof(int))==NULL)
*A = malloc((r)*(c)*sizeof(int))
/* *A = A[r][c] ?*/
*p=malloc(80*sizeof(int))
/* I understand this as 80 ints to be returned
s=malloc(100)
/*get 100 bytes?