Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a question about C program. I want to store all the datas and it\'s addre

ID: 3674467 • Letter: I

Question

I have a question about C program.

I want to store all the datas and it's address

  1. I stored datas from file to *array[50]

  below is the codes

  char temp[100];
  char *array[50];

  while.....

  fgets( temp, sizeof(temp), pFile );
  i_len = strlen(temp) + 1;
  array[i] = (char*)malloc(i_len * sizeof(char));
  strcpy(array[i], temp);

it is working. but...


  2. my question is to store it's address to the symbol array

  so i wrote it down like below. but there is a error message

  the message is " warning: assignment makes integer from pointer without a cast [enabled by default]"

  the address will be 0x0000abcd. so i want to store hex address value &array[i] to the address[j].

  below is my idea. it is ok?

  int *address[10];

  *address[j] = &array[i];

  how can i store address of array[i] to address[j]?

Explanation / Answer

Why don't you just try like this?

int address[10];

address[i] = (intptr_t)&array[j];