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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:17:32+00:00 2026-05-25T02:17:32+00:00

I was googling and found the following syntax for pointers void main() { char

  • 0

I was googling and found the following syntax for pointers

  void main()
 {
  char a[10]="helloworld";
  char *p=a;
  printf("%c",p[0]);
 }

I didnt know that Pointers can be accessed in the array form too. I used to use * for pointer operations
I used a[0] for arrays and *p for pointer operations, which is why I didnt know the other 2 things.
Now from the above, we can access the second element of array in any one of the following ways

  printf("%C",a[1]);   \\ this is the array
  printf("%c",*(a+1));  \\ this is the array using *
  printf("%c", p[1]);     \\ using the pointer 
  printf("%C",*(p+1));    \\ using the pointer

Now I wonder: which is the faster operation? I read that operations using pointers are faster, and that this is why C stays at the top for fast execution and that no other language can beat its fastness.

Now the real question: What makes the pointer operations faster?

1) *(p+0) the *(Value at address) that makes the trick or

2) p[0]

since we use

 *(a+1) or *(p+1) both are same 
  a[1] or p[1] both are same 

when a normal array can be used as *(a+1)( which uses * value at address) like a pointer. why do we use pointers for faster operations? When both have the same syntax, when normal array and pointer uses * in those syntaxes why pointers are faster?

But guys please tell me then why we use pointers ? My professor told me pointers are faster because they point to address rather a variable should be searched in the location.

  • 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-25T02:17:33+00:00Added an answer on May 25, 2026 at 2:17 am

    I wouldn’t actually expect *(ptr + offset) to be faster than ptr[offset]. In fact, on my machine, the following functions are compiled into exactly the same assembly code:

    int
    ArrayRef(int* array, int index)
    {
        return array[index];
    }
    
    int
    PointerRef(int* array, int index)
    {
        return *(array + index);
    }
    

    which (cleaned up) looks like:

    ArrayRef:
        pushq   %rbp
        movq    %rsp, %rbp
        movq    %rdi, -8(%rbp)
        movl    %esi, -12(%rbp)
        movl    -12(%rbp), %eax
        cltq
        salq    $2, %rax
        addq    -8(%rbp), %rax
        movl    (%rax), %eax
        leave
        ret
    
    PointerRef:
        pushq   %rbp
        movq    %rsp, %rbp
        movq    %rdi, -8(%rbp)
        movl    %esi, -12(%rbp)
        movl    -12(%rbp), %eax
        cltq
        salq    $2, %rax
        addq    -8(%rbp), %rax
        movl    (%rax), %eax
        leave
        ret
    

    (gcc 4.5.0, x86_64, no optimisations). Or with -O3

    ArrayRef:
        movslq  %esi, %rsi
        movl    (%rdi,%rsi,4), %eax
        ret
    
    PointerRef:
        movslq  %esi, %rsi
        movl    (%rdi,%rsi,4), %eax
        ret
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found reference by googling that led me to think the following would give
While googling I found two different sets of headers that need to be set
Anyone know what this error means? after googling I found a bunch of sites
I found a post-receive hook for Git after some googling that I use to
I want to create schema.sql instead of schema.rb. After googling around I found that
Would the following be considered as private API use? After googling I have found
Update III: After googling around I've found that this is not an uncommon problem.
I started by googling and found the article How to write INSERT if NOT
Most of the ASP.NET MVC paging solutions I have found by googling look like
Googling today I couldn't found sample or mentioning of best practice: how to escape

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.