There isn't any for each in C. The only way to go through all the elements in a structure is to write a line for each member in the structure.
At least, so far as I know.
As for you question on the header files, you have the right idea. Just think of the #include as a command along hte lines of "Copy this entire code file into this code file right here". Take a look at this:
Your Header:
Code:
struct somestruct{
int someint;
float somefloat;
char somechar;
char somestring[10];
};
Your source file:
Code:
#include <someheader.h>
int main()
{
struct somestruct NewStruct = {0,0,"",""};
goodfunction(NewStruct);
return 0;
}
struct somestruct goodfunction(struct somestruct NewStruct)
{
useful code here;
here too;
some good stuff here as well;
return NewStruct;
}
The way the compiler sees it:
Code:
struct somestruct{
int someint;
float somefloat;
char somechar;
char somestring[10];
};
int main()
{
struct somestruct NewStruct = {0,0,"",""};
goodfunction(NewStruct);
return 0;
}
struct somestruct goodfunction(struct somestruct NewStruct)
{
useful code here;
here too;
some good stuff here as well;
return NewStruct;
}
So theres no data exchange between the files, they just get merged together.
Theres a bit more to it than that (no sense confusing the issue wit ha discussion on the preprocessor stage of the compile) but for a fairly simple answer that ought to do.
As for the network end, look for tutorials on BSD Sockets. Most platforms use some version of them, even the function calls are almost identical. At the very least they all use the same concepts so if you understand the BSD implementation you'll have a good start on learning a sockets on a different platform.
[edit]You type faster than me Prelude [/edit]