If I read the code right, the intent is to split up color table values?
bytes in the file come as r,g,b,r,g,b...
You want the array to contain r,r,r...g,g,g...b,b,b...
Is that close?
if so, what do you think of:
char *glblclrtab;
glblclrtab= malloc(3*tmp);
for (int i=0; i < tmp; i++)
{
glblclrtab[i] = fgetc( ipFile);
glblclrtab[i + tmp] = fgetc( ipFile);
glblclrtab[i + 2 * tmp] = fgetc( ipFile);
}
for (int i = 0; i < tmp; i++)
{
printf("%d::%d, %d, %d \n",
i,glblclrtab[i], glblclrtab[tmp + i],glblclrtab[2*tmp+i]);
}
free (glblclrtab); // program nolonger aborts
note that
*(glblclrtab + i) is functionally equivalent to
glblclrtab[i] but the second is way easier to read.
What was the variable
clrcnt in your code?