I am trying to figure out how to pass an array index into another function.
Here I have:
for(i=0; i<file_cnt; i++){
iret1 = pthread_create(&(file[i]), NULL, get_checksum, (void*)&filenames[i]);
printf("%s\n", filenames[i]);
}
In the function get_checksum, I eventually need the index of filenames, but i is not available in that function.
In the get_checksum function,
void* get_checksum(void* a){
char *filename = (char *) a;
.....
}
I passed in a as a char pointer in relation to filenames[i].
However, I need to make computations later in the function: get_checksumthat involve getting the index of an array of sums. Therefore, I really need the index of filenames to be passed into the function get_checksum instead.
Any suggestions how to pass an array index into another function?