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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:45:35+00:00 2026-06-08T15:45:35+00:00

I got an array of char with 8 positions(char data[8];), this array has an

  • 0

I got an array of char with 8 positions(char data[8];), this array has an unsigned long long int value on it (8 bytes of size)… data[0] has the first byte of the long long int, data[1] has the second and so on.
My question is how to put that value again on an unsigned long long variable?

I’ve tried shifts but the value wasn’t equal de original value, how can i do this without changing the original array…

The order of the bytes is little endian the normal order of variables (from Hight bit to low bit)

Here is a code that prints a different value than expected.

char vec[8]={0,0,0,0,0,0,0,1};

unsigned long long value = *((unsigned long long*) vec);

std::cout<<value;

return 0;

The result should be one but instead is 72057594037927936.
Thank you for your patience.

  • 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-08T15:45:37+00:00Added an answer on June 8, 2026 at 3:45 pm

    Assuming the byte order of your data array is the same as the resultant long long value

    unsigned long long ll;
    assert(sizeof ll == sizeof data);
    memcpy(&ll, data, sizeof ll);
    

    Avoid cast-based solutions. They violate strict-aliasing semantics and, for that reason, not guaranteed to work.

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

Sidebar

Related Questions

i got a question about unsigned char array. How can i store an integer
I got an array which contains signed int data, i need to convert each
I've got class similar to this: class Krzyzowka { protected: char model[40][40]; int x,
I have this code: void fill_array (unsigned int *iarray, char *string, int max) {
I've got an array of strings that looks like this: [noindex,nofollow] or [index, follow,
I've got an array of characters which contains a string: char buf[MAXBUFLEN]; buf[0] =
I have got an array of the following structs: typedef struct _my_data_ { unsigned
Suppose if am having one 2D array I got an array , 'char input[N][N]'
I've got an array of char* in a file. The company I work for
I got the following problem: I have an array of char pointers char *opts[]

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.