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

The Archive Base Latest Questions

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

This ought to simple. Say we have a struct from a library that doesn’t

  • 0

This ought to simple. Say we have a struct from a library that doesn’t offer copying facilities. Is there an easy way to copy a variable of the type of that struct to a new variable of the same type without doing assignments for each of its sub members? Or does one have to be making special copying functions?

  • 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-16T17:12:44+00:00Added an answer on May 16, 2026 at 5:12 pm

    Well, struct types are assignable in C:

    struct SomeStruct s, d;
    ...
    d = s;
    

    It doesn’t matter, where they are defined. And there’s no need to copy “each of the sub members”. Where did you even get the idea about copying it member by member?

    Of course, the assignment will perform shallow copying only. If you need deep copying, you need a library-provided copying routine. If there’s none, you will have to implement it yourself. In order to do that you will need full knowledge of the actual deep-memory organization of the structure. If you don’t know it (i.e. if it is not documented), you are out of luck – proper deep-copying is impossible.

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

Sidebar

Related Questions

I'm trying to do something that ought to be pretty simple. I have a
I have two simple while loops in my program that I feel ought to
this ought to be simple, but it doesn't seem to be working for me.
This should be a simple one: I have an observableArray object called To in
This ought to be simple but I just can't figure this one out: The
This seems like it ought to be simple, but I've tried both try {}
This ought to be pretty simple, maybe use a regex but I would think
This ought to be very simple in Rails, but I'm still learning... My code
I have a utility that draws a simple arc, either using SVG or, as
It seems this ought to be dead simple, but I'm stuck. I've written some

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.