I'm writing a program that must normalize audio *.wav file.
There is a task "to display header's data": ChunkId, ChunkSize and so on.

I want to make a function named display_hdr (In order to have less code in the main.c file, so it will become esier to read this code). To do this I have to pass this function header's variable (variable of type header) as argument, but it writes

Is there a reason not to pass a pointer? Doing so will probably give better performance. Besides that, make sure the struct is defined before the prototype. Also, you may want to see Passing struct to function

The sanity check ensures that the function will not crash if it is called with a NULL argument, although __func__ is a C99 addition. If you are using an older standard it may be available as an extension (or just hardcode the name of the function ;) )

Your main() function should now pass a pointer to a header object into display_hdr(), or to keep it simple in this example just the address of hdr, something like that...

I'm sorry, I don't understand what you are saying here. I was referring to the output of the sample code I demonstrated.
–
Harry K.May 18 '13 at 19:32

Oh, I think I got what your comment means. Those 0s at the output of my example, are due to the near initialization of hdr. It's a quick hack to set all the fields of the hdr variable to their zero values (something like using memset() on it). Since hdr is a struct, the proper way of initializing it would be by listing explicitly the values of all its fields, inside the curly braces: see here for some examples (since C99 you may use name-value pairs).
–
Harry K.May 18 '13 at 19:52

I appreciate your help. But I'm good with variable hdr. I can accaee to any field (chunk, subchunk and so on ...) Maybe, I didn't understand you again..?
–
Yulian KhlevnoyMay 18 '13 at 19:56

In my example, the line header hdr = {0}; defines the hdr variable and initializes its memory to zero's. So the output produced by calling display_hdr(hdr); at the next line gives all those 0s on your screen. But this is kinda off-topic, it was just some additional info ;) What's more important imho is to pass the address of hdr into your functions (this means you have to re-write them) because it saves you memory and in many cases it also improves speed.
–
Harry K.May 18 '13 at 20:06