2015-09-22 09:24 AM
Hello.
i have this structure definition:(ex)structure example_str{ int a[10]; int b[10];}and a function with this definition:void test(example_str *temp); i want to change the value that pointer temp is locating with out using another variable to define.(not to do like this:example_str test = * temp.test.a[1] = 10 ;)i want to define arrays value directly.I would be very thankful if everybody help me.thank you #pointer2015-09-22 09:37 AM
Not 100% sure of what the question is, let's start with something that makes sense and discuss from there.
typedef struct _example_str {
int a[10];
int b[10];
} example_str;
void test(example_str *temp, int x)
{
temp->a[1] = x;
}
int main(void)
{
example_str foo = { 0 }; // cleared
example_str bar = { 0 }; // cleared
test(&foo, 11);
printf(''%d
'', foo.a[1]);
test(&bar, 22);
printf(''%d
'', bar.a[1]);
while(1);
return(0);
}
2015-09-22 09:40 AM
Or are you looking to do this?
example_str foo = { {1, 2, 3}, {4, 5, 6} };
2015-09-22 10:46 PM
Thank you Clive. In this post you answer me clearly and problem solved.
thank you again..