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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:27:38+00:00 2026-06-03T02:27:38+00:00

If I write the code like this below? int arr[] = {6, 7, 8,

  • 0

If I write the code like this below?

int arr[] = {6, 7, 8, 9, 10};
int *ptr = arr;
*(ptr++)+= 123;

what’s the elements in the arr[] now?

I originally thougt the arr[] now should be {6, 130, 8, 9, 10}, but actully the result is {129, 7, 8, 9, 10}, I don’t know why?

In my opinion, ptr++ is in the bracket, so the ptr should increase first, isn’t it? after it increased one, it should point to the second element in the array.

  • 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-03T02:27:40+00:00Added an answer on June 3, 2026 at 2:27 am

    The value of ptr++ is the value of ptr before any increment (the side-effect is incrementing ptr at some time during the evaluation of the expression).

    That is the value that is dereferenced in *(ptr++).

    If you dereference ptr in a subsequent expression, it points to the next element, the one with value 7.

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

Sidebar

Related Questions

I was wondering how to better write code like this so that it leverages
I occasionally write code something like this: // file1.cpp #define DO_THIS 1 #if DO_THIS
In code, if I write a code line like this: GClass<Double> x = new
I'm trying to write a regular expression for html code that looks like this:
Is it worth to write code like the following to copy array elements: #include
I want to be able to write code like this: HWND hwnd = <the
Log.d(TAG, Build.VERSION_CODES.ICE_CREAM_SANDWICH: + Build.VERSION_CODES.ICE_CREAM_SANDWICH); I write code like this, I used the sdk4.0 to
If I'm using a Hashtable , I can write code like this: object item
When I write code in Python with exception handling I can write code like:
Firefox 3.5.3 (at least) allows me to write code like : var array =

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.