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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:28:58+00:00 2026-05-31T13:28:58+00:00

I recently did an assignment using bit masking and shifting to manipulate a 4

  • 0

I recently did an assignment using bit masking and shifting to manipulate a 4 byte int.

I got to wondering if it was possible to set a char pointer to the start of the int variable and then step through the int as if it was a 1 byte char by using the char pointer.

Is there a way to do this or something similar? I tried to set the char pointer to an int but when I step ahead by 1 it jumps 4 bytes instead.

Just trying to think of alternative ways of doing the same thing.

  • 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-31T13:28:59+00:00Added an answer on May 31, 2026 at 1:28 pm

    Of course you can, this code shows the behavior:

    #include <stdio.h>
    
    int main()
    {
      int value = 1234567;
      char *pt = (char*) &value;
    
      printf("first char: %p, second char: %p\n", pt, pt+1);
    }
    

    This outputs:

    first char: 0x7fff5fbff448, second char: 0x7fff5fbff449
    

    As you can see difference is just 1 byte as intended, this because arithmetic on pointers has been done after casting the type to a smaller kind of data.

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

Sidebar

Related Questions

I recently did some performance testing and analysis of an ASP.NET application using out-of-process
I recently did some work modifying a Python gui app that was using wxPython
I recently got an assignment to use the EXTEND OPEN command to add data
I had been using eclipse in Ubuntu 9.10 without any problems. Recently I did
I recently did the Chris Coyier tutorial from the css-tricks.com weblog #38: Basics &
I recently did an online installation of SP1 for VS 2008, where installation of
I recently wrote a piece of code which did SomeClass someObject; mysqlpp::StoreQueryResult result =
Recently our Subversion (SVN) server was changed and we did a svn switch .
I re-did my portfolio site recently, and I'm trying to make it so that
Did any one have luck recently register Visual studio 2008 express C# product? Look

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.