PMG
PMG

Reputation: 33

Statement with pointers appears to be missing an operator

I have encountered the following statement in C code and do not understand how to interpret it.

Recognizing the 2nd operand as a pointer reference (*a), it looks to me like the statement is missing an operator between the operands (interpreting * as pointer reference, not multiply).

I have run the code containing this statement, and it completes without errors, so I believe the statement is valid, but I just don't understand what its doing.

Here it is:

val +=input_ptr[a] *filter_ptr[b];

Thank you.

Upvotes: 2

Views: 85

Answers (1)

You have two arrays: input_ptr and filter_ptr, you can get the value stored in those cells by doing, lets say, input_ptr[0] so :

val is increased with the value stored at index 'a' in array input_ptr multiplied by the value stored at index 'b' in array filter_ptr

Upvotes: 5

Related Questions