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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:50:11+00:00 2026-06-12T01:50:11+00:00

So I have a really large pointer, p, pointing to roughly 40 bytes. I

  • 0

So I have a really large pointer, p, pointing to roughly 40 bytes.

I also know that these 40 bytes enclose ints, chars, and other pointers. I know how to hop across these 40 bytes too.

For debug purposes I want to print out these contents. How do I do that?

For example, lets say I know that at p+16 there is an int and I want to print this int. Is there a way to “print 4 bytes from this address and format that as an int” in C?

  • 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-12T01:50:12+00:00Added an answer on June 12, 2026 at 1:50 am

    Yes, just cast & dereference. Assuming you have p already set up:

    int i = *(int *)(p + 16);
    printf("%d\n", i);
    

    Watch out for potential alignment issues – for example, this code:

    int i = *(int *)(p + 3);
    

    might cause an exception on some processors (assuming p is safely aligned for an int, that is). In that case, you’ll need to assemble the bytes yourself. Here’s an example assuming a 4-byte integer and 8-bit bytes. Make sure to watch out for endianness:

    unsigned char *p;
    int bigEndian = p[3] << 24 + p[4] << 16 + p[5] << 8 + p[6];
    int littleEndian = p[3] + p[4] << 8 + p[5] << 16 + p[6] << 24;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a really large table consisting of 8 fields (I know, unprecise). In my
So I have this really large object that I use to control things in
Let's say I have a really large file foo.txt and I want to iterate
I have done database optimization for dbs upto 3GB size. Need a really large
In software companies I have seen it's really hard to work on very large
I have really large file with approximately 15 million entries. Each line in the
Background I have a large TIFF file that is compressed with JPEG (new, compression
We have a large C code base that has been developed over several decades.
Problem Suppose I have a large array of bytes (think up to 4GB) containing
So I have this really large method I wrote. If it's given a stack,

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.