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

  • SEARCH
  • Home
  • 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 8552845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:31:05+00:00 2026-06-11T14:31:05+00:00

This might be a pretty basic question but I am a newbie in C

  • 0

This might be a pretty basic question but I am a newbie in C so please bear with me.

I am going through some documentation for a firmware written in C where I came across this:

typedef struct {
                 int x;
                 int arr[10];
               } sx;

Then I have a function where a pointer to that type is being passed.

int f(sx xtype *sp, int i){
                            return sp -> arr[i];
                          }

I am not sure where about two things:
From my Java experience I think the first snippet is equivalent to a superclass much like Object class in Java and then the second snippet is using a subclass of sx. However I am not sure. Can anyone please confirm?
From my little C experience so far, I think more easy-to-understand way to pass a pointer to the type would be as follows:

typedef struct xtype {
                 int x;
                 int arr[10];
                 } sx;

int f(sx *sp, int i){
                     return sp -> arr[i];
                    }

But I just suspect I am missing something from this picture.
Thanks in advance!

  • 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-11T14:31:06+00:00Added an answer on June 11, 2026 at 2:31 pm

    This is unusual syntax. I suspect that xtype is a macro defined somewhere and could look something like this

    #define xtype const
    

    At any rate, the declaration of a variable sx xtype *sp does not say that sp refers to a subtype xtype of sx or this is the worst pre-processor magic I’ve seen in a long time.


    As for your second example, this doesn’t model sub-classing, either. What this:

    typedef struct A {
      /* ... */
    } B;
    

    says is that struct A is the same as B. It’s a typedef: It just defines a new type, a short rephrased version of the longer name.

    void func(struct A);
    void func(B); // exactly equivalent
    

    It has nothing to do with inheritance.

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

Sidebar

Related Questions

okay this might be a pretty lame and basic question but its stuck in
This might be a pretty basic question, but how do you add new users
This might seem like a very easy question for some of you folks, but
This might be a very basic question but it confuses me. Can two different
This might be a pretty basic question, or peculiar to my set up (hopefully
This might be pretty basic, but was very curious to know. Here's the code
I guess this is going to sound like a pretty basic question to any
I know this is a pretty basic question, but I don't know how to
Having just started with Objective-C, this might be a pretty basic question. In objective-c,
This might be a simple question but I've searched and searched and can't find

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.