I have a nested structure as follows:
typedef struct {
float mz_value;
float int_value;
} spectrum;
typedef struct {
// stuff
spectrum* spectra; /* Nested struct */
// more stuff
} chromatogram;
I allocate memory in my code as follows:
(chrom+i)->spectra=malloc(sizeof(spectrum)*1024);
I then want to assign some values to it and I have been trying all kinds of syntaxes similar to:
((chrom+i)->(spectra+j))->mz_value = (float)*(array_buffer+j);
// array_buffer is a float*
Yet this keeps giving me an error that I am failing at proper usages of braces, the only problem is that I can’t figure out where o.O Any help would be greatly appreciated before I regret trying to use a nested structure.
Cheers,
Bas
Try
Or, preferably, use array notation, which is much clearer in this case: