Array pointer as function argument?
Hello,
I have been asked to implement a method
Code:
void word_not(lc3_word_t *R, lc3_word_t *A)
which, as you can see, takes 2 pointers to a array of BITS, defined as follows:
Code:
typedef enum {
ZERO = (uint8_t) 0, ONE = (uint8_t) 1
} BIT;
typedef BIT lc3_word_t[16];
The main method invokes the function:
Code:
word_not(&result, &a_value)
which passes the address of two lc_word_t types to word_not. The function is supposed to negate each bit in a_value (NOT function) and write it into the corresponding bit in result.
What should I put in the body of word_not to accomplish this? I begin by looping from 0 to 15 (a total of 16 times, the length of the word type), but I am not sure how to check & store elements in arrays when I am given only pointers (addresses?) to the arrays. I am very confused what the data fields for the pointer arugments look like when addresses are passed into them.
I have tried different things like making BIT pointers (BIT *) but when I print the contents of result it always appears to have addresses instead of BITs. What should I do?