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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:22:21+00:00 2026-05-26T16:22:21+00:00

Possible Duplicate: Declaring pointers; asterisk on the left or right of the space between

  • 0

Possible Duplicate:
Declaring pointers; asterisk on the left or right of the space between the type and name?
Does it matter where I place the asterisk when declaring pointers in C++?

I searched, but my keywords don’t seem to fit. I’m pretty sure this question has already been asked., so point me in some direction if you know a link or something !

My question is, why do so many people use

TypeIdentifier *varname;

Instead of

TypeIdentifier* varname;

which is much more logical to me as the * modifies the type and not the variable name.

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

    In both C and C++, the declaration syntax (mostly) follows usage.

    The declaration

    int *n;
    

    can be read as “n is of type int*“, or as “*n is of type int“. And if you take a look at the language grammar, the latter corresponds more closely to the way it’s parsed.

    For a type consisting of just a name (like int) and a *, it doesn’t make a whole lot of difference, but it matters for more complex declarations.

    The usual tendency is to use int *n; in C and int* n; in C++. The latter is because that’s Stroustrup’s personal preference. His point, I think, is that the “n is of type int*” reading is more natural, and the complexities can be avoided by not writing complex declarations. For example, whichever spacing you prefer, it’s better to write

    int *a;
    int b;
    

    than either

    int* a, b;
    

    or

    int *a, b;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicates: Declaring pointers; asterisk on the left or right of the space between
Possible Duplicate: What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
Possible Duplicate: In C, what is the correct syntax for declaring pointers? When I
Possible Duplicate: What does template <unsigned int N> mean? Hi ! Are non-type template
Possible Duplicate: Difference between declaring variables before or in loop? Is there any (or
Possible Duplicate: What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
Possible Duplicate: In CSS what is the difference between “.” and “#” when declaring
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: When to use final What is the use of declaring final keyword
Possible Duplicate: Typedef pointers a good idea? I've seen this oddity in many APIs

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.