The way you're trying to do things more or less defeats the purpose of a struct. Why would you bother putting it all together if you always had to deal with the struct members individually? It'd be useful as a sort of namespace, but that's about it.
Thankfully, C's not like that:
Code:
#include <stdio.h>
struct info
{
int a, b, c;
};
void f(struct info info)
{
printf("%d %d %d\n", info.a, info.b, info.c);
}
int main(void)
{
struct info info = { 10, 20, 30 };
f(info);
return 0;
}
You can just pass a struct around; you needn't try to pass each individual member.
You'll probably want to pass a pointer around instead of the struct itself (this becomes more relevant the larger your struct gets):
Code:
#include <stdio.h>
struct info
{
int a, b, c;
};
void f(struct info *info)
{
printf("%d %d %d\n", info->a, info->b, info->c);
}
int main(void)
{
struct info info = { 10, 20, 30 };
f(&info);
}
x->y is the same as (*x).y; that is, dereference a struct (or union) pointer and then access a member.