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 7953747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:13:47+00:00 2026-06-04T03:13:47+00:00

Here is part of my code. I would like to initialize only the arraylist[0]

  • 0

Here is part of my code. I would like to initialize only the arraylist[0] as arraylist[0].x = 0 and arraylist[0].y = 0. I do not need to initialize the rest of the struct array. How can I do it? Thank you.

#include <stdio.h>
struct example {
    int x;
    int y;
};
struct example arraylist[40];

int main(int argc, char *argv[]){
    printf("%d\n %d\n", arraylist[0].x, arraylist[0].y);
    return 0;
}
  • 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-06-04T03:13:48+00:00Added an answer on June 4, 2026 at 3:13 am

    You can initialise any particular element of the struct array.

    For example:

    struct example arraylist[40] = { [0]={0,0}}; //sets 0th element of struct
    
    struct example arraylist[40] = { [5]={0,0}}; //sets 6th element of struct
    

    This is called Designated Initializers which used to be a GNU extension before C99 adapted it and is also supported in standard C since C99.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a fix for this. here is just part of my code <?php
Here is part of the code. $DatabaseArray=Array("Cooking","look","I cant","Walking the dog to the park","washing","talk","one"); $largest
Here's part of my code for a jQuery word counter. My question is: how
Here is a part of my html code (video urls marked with a django-template
Just putting part of some code here where I am writing two values to
Here is the first part of my controller code: public class ControlMController : Controller
EDIT Sorry I forgot the most important part here. Each key can have more
I would like to bind a list box to an observable collection in code
I would like to show blog details when a link is clicked. Here is
I would like to perform an audit as part of a unit test that

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.