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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:06:27+00:00 2026-05-15T04:06:27+00:00

I have a c pointer to a structre type called uchar4 which looks like

  • 0

I have a c pointer to a structre type called uchar4 which looks like

{
    uchar x; 
    uchar y; 
    uchar z; 
    uchar w;
}

I also have data passed in as uint8*. I’d like to create a uchar* pointing to the data at the uint8* so I’ve tried doing this:

uint8 *data_in;
uchar4 *temp = (uchar4*)data_in;

However, the first 8 bytes always seem to be wrong. Is there another way of doing this?

EDIT:

the input data = 32 43 F6 A8 88 5A 30 8D 31 31 98 A2 E0 37 07 34

the output data = 32 88 31 E0 37 07 34 8D 31 31 98 A2 E0 37 07 34

The first half is always these seemingly random values

  • 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-15T04:06:28+00:00Added an answer on May 15, 2026 at 4:06 am

    Behold, the humble union:

    #include <stdio.h>
    
    typedef struct {
        unsigned char x, y, z, w;
    } xyzw;
    
    typedef union {
        xyzw x;
        unsigned int i;
    } ixyzw;
    
    
    unsigned int xyzw_to_i(ixyzw *p)
    {
        return p->i;
    }
    
    int main()
    {
        xyzw x = {1, 2, 3, 4};
    
        printf("sizeof unsigned char %d\n", sizeof(unsigned char));
        printf("sizeof unsigned int  %d\n", sizeof(unsigned int));
        printf("sizeof xyzw          %d\n", sizeof(xyzw));
        printf("sizeof ixyzw         %d\n", sizeof(ixyzw));
    
        printf("xyzw = { %d, %d, %d, %d }\n", x.x, x.y, x.z, x.w);
        printf("i    = 0x%08x\n", xyzw_to_i((ixyzw *) &x));
        return 0;
    }
    

    which on my machine happens to yield:

    sizeof unsigned char 1
    sizeof unsigned int  4
    sizeof xyzw          4
    sizeof ixyzw         4
    xyzw = { 1, 2, 3, 4 }
    i    = 0x04030201
    

    but one can’t count on this behavior across compilers or machines.

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

Sidebar

Related Questions

I have a pointer which points to a function. I would like to: if
I have a callback procedure: type TInitCallback = procedure (var Data: Pointer); The idea
I have a pointer of a structure type that I made. On program start
Suppose I have some pointer, which I want to reinterpret as static dimension array
I have a C structure that looks like this typedef struct event_queue{ Event* event;
I have a pointer in a struct. And I passed a struct pointer to
I have this warning warning: assignment from incompatible pointer type in this line: data1->transformed_block[l]
seeking some advice here. I have a structure which contains a pointer to another
I have an abstract data type that points to a concrete data type structure.
I'm working in a code that has a data structure like this: type TData1

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.