c - Creating an array of structs -
So I'm trying to modify some code and I need to make a straight one. The structure is declared as follows:
Type-tof strip header {int sample_rate; Int num_channels; Int bit_res; Int num_samples; Four * data; } Header; Typedef Structure header * header_p; What is the correct way to create and use an array of this structure? I was making some effort on the lines of this:
header_p fileHeader; ... fileHeader = (header_p) malloc (sizeof (header) * (argc-1)); Which seems to work, but I'm not sure how to use the array correctly.
Edit: (Some of my questions have been cut in some way) when I use the array like this:
file header [0] = function header Returns returns;
I get the following compilation error:
while incompatible type while assigning to type ???? Struct header One by type Header_pac Edit: After the lundin advice to remove the silly type that hides student pointers it was easy to understand what was going on. It was easy to see that Alex was right about the need to deflect my pointer. I am going to accept Alex's answer because technically my problem was.
here:
file header [0] = function that Depends on the header; You forgot Pointer's connection.
file header [0] = * function_returning_header_p ();
Comments
Post a Comment