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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:45:12+00:00 2026-05-19T16:45:12+00:00

Just a silly question: I have a simple counter, but it seems that it

  • 0

Just a silly question:
I have a simple counter, but it seems that it gives the double value of what I expect.

short int *new = 0;
++new;
NSLog(@"Items: %hi", new);

And this returns:

Items: 2

Relatively new to Cocoa, and still working out the little details as is clear form above…

  • 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-19T16:45:13+00:00Added an answer on May 19, 2026 at 4:45 pm

    You don’t have an integer variable, you have a pointer to an integer variable (a short integer, to be specific). It increments by 2 because short integers are two bytes long. A pointer variable holds a memory address of another value. Incrementing a pointer means, “make this pointer point to the next thing in memory”, where “thing” is the type of value the pointer was declared to point at. A pointer to double would increment by 8 each time.

    The “*” in the declaration makes it a pointer. If you just want an int, you’d just write

    short int new = 0;
    ++new;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys I know this question is silly but just to make sure: Having in
Very silly question but i have messed up on it. My question is, i
I have a silly question. Just wanted to know if it is possible. I
This question is just something that I have been thinking about lately. Can a
I've just started programming with Java, so might appear as silly question, but I
Okay, Now admittedly this sounds like a silly question; But, I actually have a
This is a silly simple question I’m sure, but since I’m new to Magento,
I have to warn you: the question may be rather silly, but I can't
It might be a silly question but I am just curious about what goes
This might just come as a very silly question, but i am really frustrated

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.