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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:43:31+00:00 2026-06-13T16:43:31+00:00

Specifically, I was wondering if I could make something like this: typedef struct {

  • 0

Specifically, I was wondering if I could make something like this:

typedef struct {
    char *s; /* still a cstr, with '0' bit at end */
    size_t len;
} str;
str *newstr(char *s) {/*...*/};
void freestr(str *s) {/*...*/};

and do things like this (treat it as a cstr with stdlib/string functions):

int main() {
    str *s = newstr("hello");
    printf("The first character of '%s' is '%c'", *s, (*s)[0]);
    freestr(s);
}

If not, it’s not a big deal—and, of course, I’m not really concerned about wasting a byte.

  • 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-13T16:43:32+00:00Added an answer on June 13, 2026 at 4:43 pm

    No, that’s a place where the standard explicitly forbids placing any padding. The address of the first member of a struct and the address of the struct must be the same.

    Section 6.7.2.1 (15) in the n1570 draft of the C2011 standard states:

    Within a structure object, the non-bit-field members and the units in which bit-fields reside have addresses that increase in the order in which they are declared. A pointer to a structure object, suitably converted, points to its initial member (or if that member is a bit-field, then to the unit in which it resides), and vice versa. There may be unnamed padding within a structure object, but not at its beginning.

    (emphasis mine)

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

Sidebar

Related Questions

I was wondering if you could overload functions in PHP, specifically in CodeIgniter. For
I was wondering how I could set up css pseudo classes, specifically hover so
I'm wondering what is the best way to make data thread-safe. Specifically, I need
I was wondering how I could overload a standard function in php. Specifically, I'm
This is bizarre, I was wondering if anyone could shed some light on why
I'm working on an application in ASP.NET, and was wondering specifically how I could
Specifically I'm wondering how to do something similar to the rotate method. public void
Can this object pool cause visibility problems with multiple threads? I'm specifically wondering about
Specifically, I am wondering whether I should create a GKScore or save the score
This probably sounds like a stupid question, but I'm going to give it a

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.