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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:52:29+00:00 2026-06-12T17:52:29+00:00

I have a structure as: //GUID structure typedef struct { var8 octet[16]; } GPTGUID_t;

  • 0

I have a structure as:

//GUID structure
typedef struct {
    var8 octet[16];
} GPTGUID_t;

And a long #define as:

#define PTYPE_MRP_UPPER     0x4db80b5ce3c9e316ULL
#define PTYPE_MRP_LOWER     0xae1502f02df97d81ULL

I wish to copy UPPER part in octet 0 to 7 and LOWER in 8 to 15.
Unfortunately all attempts including memcpy has failed and given segfault.

I tried something as:

        strcpy(guid.octet[0], PTYPE_MRP_UPPER);
        strcpy(guid.octet[8], PTYPE_MRP_LOWER);

And also,

memcpy(guid.octet[0], PTYPE_MRP_UPPER, sizeof(PTYPE_MRP_UPPER));
memcpy(guid.octet[8], PTYPE_MRP_LOWER, sizeof(PTYPE_MRP_LOWER));

Both have failed.

Just as a side note:

typedef unsigned char       var8;
typedef unsigned short      var16;
typedef unsigned int        var32;

However, I am able to extract the individual octets as:

    memcpy( guid.octet, pHdr->partTypeGUID, sizeof(GPTGUID_t));//copy the partitionTypeGUID
    p1 = getvar64(guid.octet[0]);
    p2 = getvar64(guid.octet[8]);

where, #define getvar64(x) (*(var64*)(&x))

  • 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-12T17:52:30+00:00Added an answer on June 12, 2026 at 5:52 pm

    The value 0x4db80b5ce3c9e316ULL is not a string, so strcpy treats is as a pointer and with a value like that it’s pointing way wrong.

    You also can’t use strcpy as it copies until it finds a zero byte (the character '\0'). Use memcpy instead.

    You also doesn’t pass pointers to the memcpy function, but values. You should turn on more warnings because the compiler will not like it, but not enough to make it an error apparently.

    Try to call memcpy like this:

    unsigned long long val;
    
    val = PTYPE_MRP_UPPER;
    memcpy(&guid.octet[0], &val, sizeof(val));
    val = PTYPE_MRP_LOWER;
    memcpy(&guid.octet[8], &val, sizeof(val));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a structure: typedef struct stock { const char* key1p2; // stock code
I have C++ code that maps GUID(unsigned long) to structure. #include <string> #include <map>
I have a table with a structure like the following: LocationID AccountNumber long-guid-here 12345
In rpc.h, the GUID structure is declared as follows: typedef struct _GUID { DWORD
I have a structure like this struct structure { BaseObject &A; //BaseObject has a
I have the following structure: MyClass { guid ID guid ParentID string Name }
I have the following database structure: Event table Id - Guid (PK) Name -
Question: When you have a .NET GUID for inserting in a database, it's structure
I have the following object structure. public class Study { public Guid? PreviousStudyVersionId {
Lets say we have the following document structure: class BlogPost { [MongoIdentifier] public Guid

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.