Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7528049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:16:12+00:00 2026-05-30T04:16:12+00:00

I have a nested structure as follows: typedef struct { float mz_value; float int_value;

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:16:13+00:00Added an answer on May 30, 2026 at 4:16 am

    Try

    ((chrom+i)->spectra+j)->mz_value = (float)*(array_buffer+j);
    

    Or, preferably, use array notation, which is much clearer in this case:

    chrom[i].spectra[j].mz_value = (float)array_buffer[j];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table structure as follows. Now I need to sort these nested
In Perl, when you have a nested data structure, it is permissible to omit
Hi currently I have a nested XMl , having the following Structure : <?xml
i'm working on a app where i have nested tree structure i.e. as below
Suppose you have a nested element structure, for example a ContextMenu with MenuItems: <ContextMenu
Hi I have writen an Nested Structure in C# . Find the code snippet
So I have a nested div structure and I would like to get the
I have a nested simple XML structure that I load with PHP's simpleXML. Some
I have a query that produces the following output in a nested set structure:
I have this nested list structure. My tree can go to n level. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.