I have an array product[6] and a pointer (*productPtr) pointing to this array. When I pass the pointer as an argument to a function called productCheck and try to print one of the characters, I get an invalid reading of the characters from the product array. Any help as to why this is happening is greatly appreciated. For example if i = 3, instead of reading 'u', the output is '{'.
int i = 3;
char product[6] = "xddua";
char * productPtr;
productPtr = product;
bool productCheck(int i, char * productPtr);
productOk = productCheck(i, &product);
bool productCheck(int i, char * productPtr)
{
printf("product is %c\n", *productPtr + i);
*productPtr + i->*(productPtr + i)or arguably more clearly/simplyproductPtr[i]productOk = productCheck(i, &product);product(the second parameter) is a 'bare name of an array' so will be the address of the first byte of the array, this statement is trying to take the address of the address of the array. Suggest removing the&beforeproducechar * productPtr; productPtr = product;This pair of statements are not used so can be removed