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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:51:21+00:00 2026-05-11T01:51:21+00:00

Does anyone have any good articles or explanations (blogs, examples) for pointer arithmetic? Figure

  • 0

Does anyone have any good articles or explanations (blogs, examples) for pointer arithmetic? Figure the audience is a bunch of Java programmers learning C and 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. 2026-05-11T01:51:22+00:00Added an answer on May 11, 2026 at 1:51 am

    First, the binky video may help. It’s a nice video about pointers. For arithmetic, here is an example:

    int * pa = NULL; int * pb = NULL; pa += 1; // pa++. behind the scenes, add sizeof(int) bytes assert((pa - pb) == 1);  print_out(pa); // possibly outputs 0x4 print_out(pb); // possibly outputs 0x0 (if NULL is actually bit-wise 0x0) 

    (Note that incrementing a pointer that contains a null pointer value strictly is undefined behavior. We used NULL because we were only interested in the value of the pointer. Normally, only use increment/decrement when pointing to elements of an array).

    The following shows two important concepts

    • addition/subtraction of a integer to a pointer means move the pointer forward / backward by N elements. So if an int is 4 bytes big, pa could contain 0x4 on our platform after having incremented by 1.
    • subtraction of a pointer by another pointer means getting their distance, measured by elements. So subtracting pb from pa will yield 1, since they have one element distance.

    On a practical example. Suppose you write a function and people provide you with an start and end pointer (very common thing in C++):

    void mutate_them(int *begin, int *end) {     // get the amount of elements     ptrdiff_t n = end - begin;     // allocate space for n elements to do something...     // then iterate. increment begin until it hits end     while(begin != end) {         // do something         begin++;     } } 

    ptrdiff_t is what is the type of (end – begin). It may be a synonym for ‘int’ for some compiler, but may be another type for another one. One cannot know, so one chooses the generic typedef ptrdiff_t.

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

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 67k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Or did I get the connection between compression and entropy… May 11, 2026 at 11:42 am
  • added an answer This is expected behaviour. From the C++ standard: If no… May 11, 2026 at 11:42 am
  • added an answer The best way would probably be to use regular expressions. May 11, 2026 at 11:42 am

Related Questions

Does anyone have any good articles or explanations (blogs, examples) for pointer arithmetic? Figure
Does anyone have any good starting points for me when looking at making web
Does anyone have any good links for developing custom field and content types that
Does anyone have any good suggestions for creating a Pipe object in Java which
Does anyone have any good resources for refining my skills in developing class diagrams?
Does anyone have any good scenarios for teaching relational databases and SQL? All the
Does anyone have any suggestions for a good approach to finding all the CPAN
Does anyone have any recommendations for a good, fast, make tool? SCons? KJam? Something
Does anyone have any recommendations of tools that can be of assistance with moving
Does anyone have any experience getting MSTest to copy hibernate.cfg.xml properly to the output

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.