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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:25:47+00:00 2026-05-27T23:25:47+00:00

Wanting to truncate addresses for clarity. Not looking for improved code, just why the

  • 0

Wanting to truncate addresses for clarity.
Not looking for improved code,
just why the hex code subtraction does’t seem to work properly.

First result with ‘zero’ being subtracted from ‘cname’ and ‘arptr’:

address of 'cname' is 0x7fff5fbff720
and of 'arptr' is     0x7fff5fbff720

Wanting to truncate unneeded digits for clarity
I subtract 0x7fff5fbf0000 thinking I’ll get
0x00000000f720, but:

Second result with ‘trunker’ being subtracted from ‘cname’ and ‘arptr’:

address of 'cname' is 0xffff00014082f720
and of 'arptr' is     0xffff00014082f720
#include <stdio.h>
#define trunker 0x7fff5fbf0000
#define zero    0x000000000000

int main(void) {

    char cname[3][3] = {'a','b','c','e','f','g','i','j','k'};
    char (* arptr)[3];

    arptr = cname;

    printf("address of cname is %p\nand of arptr is     %p\n",
    cname-zero,arptr-zero);   //replace zero with trunker 
                              //to truncate first 8 digits

    return 0;

}

Using Xcode on OS X

Thanks and Happy New Year 2012

  • 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-27T23:25:47+00:00Added an answer on May 27, 2026 at 11:25 pm

    Pointer arithmetic is performed in units of the thing being pointed to, not in units of bytes/chars.

    You could try this instead:

    printf("address of cname is %p\nand of arptr is     %p\n",
        (char*)cname-zero, (char*)arptr-zero);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not wanting to enter into the debate of wiring up event handlers in code
Not wanting to re-invent the wheel or anything, I was wondering if there's a
Wanting to add a thumbs up/down rating system to my Tumblr Page, just like
Wanting to make sure I'm using classes properly. The main script accepts this from
Just wanting to confirm the usage of the Nitrogen Authentication and Authorization API. The
Not wanting this question to be too long, I will skip to an example:
Just wanting to get a bit more of an idea about how Phonegap/Titanium packages
Without wanting to bug sacha too much, does anyone know what the Cinch V2
I am wanting to clarify if it is not possible to declare types in
Wanting to check if I missed a setting somewhere, or if I'm just using

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.