#include <stdio.h>
void changeValues(struct ITEM *item[]);
struct ITEM
{
int number;
};
int main(void)
{
struct ITEM items[10];
for (int i = 0; i < 10; i++)
{
items[i].number = i;//initialize
printf("BEFORE:: %d\n", items[i].number);
}
changeValues(items);
for (int i = 0; i < 10; i++)
{
items[i].number = i;
printf("AFTER:: %d\n", items[i].number);
}
return 0;
}
void changeValues(struct ITEM *item[])
{
for (int i = 0; i < 10; i++)
item[i] -> number += 5;
}
I am trying to pass an array of structures to a function. I need to change the values of the structures members within the function by reference and not value. For some odd reason when I print the results after the function is called the values remain the same as they were prior to the function call.