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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:30:43+00:00 2026-06-03T17:30:43+00:00

Plain C, on Windows 7 & HP machine. int main(void) { unsigned int a

  • 0

Plain C, on Windows 7 & HP machine.

int main(void) {

    unsigned int a =  4294967295;
    unsigned int *b = &a;

    printf("before val: '%u'\n", *b); // expect 4294967295, got 4294967295

    memset(b+2, 0, 1);

    printf("after val: '%u'\n", *b);
    // little endian          4th      3rd     2nd       1st
    // expect 4278255615 - 11111111 00000000 11111111 11111111
    // got    4294967295 - 11111111 11111111 11111111 11111111

    return 0;

}

I want to set the third byte of the integer to 0x0, but is remains the same. Any ideas? Thank you.

On my machine, int is 32 bits.

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

    Pointer addition/subtraction does not move by only one byte – it moves by the size of the type of the object being pointed to.

    That is to say (assuming 4-byte integers),

    int *p = 0x00004
    int *q = p+1;
    assert(q == 0x00008)
    

    Basically, it’s the same as if you used the index of operator:

    int *q = &p[1]
    

    If you want to increment a pointer by one, cast it to a unsigned char *. The way you did it, you were overwriting memory that was not part of the variable a and possibly overwriting existing data for something else.

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

Sidebar

Related Questions

The Scripting.FileSystemObject TextStream object supports Windows style Unicode and 'plain text' modified by the
I've got this plain HTML: Many things are in my room: a bed, a
I've got a legacy c++ win32 application, and extending it using wpf windows does
How to check ymax and xmax in a console window, under Windows, using plain
I plan to write a Desktop Client for Windows and Mac. It will be
Plain-vanilla NHibernate setup, eg, no fluent NHibernate, no HQL, nothing except domain objects and
Plain text, contact info, image are differences. So I want to know how to
In plain English, what are the disadvantages and advantages of using SET TRANSACTION ISOLATION
It is possible in plain Java to override a method of a class programmatically
I am writing a plain vanilla c++ console app using VS 2008. When I

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.