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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:13:55+00:00 2026-06-16T04:13:55+00:00

#include <stdio.h> int main() { char a[] = hello; char *ptr = a; printf

  • 0
#include <stdio.h>

int main()
{
    char a[] = "hello";
    char *ptr = a;
    printf ("%c\n",*ptr++);//it prints character 'h'.
    printf ("%c\n",*ptr);//it prints character 'e'.
    return 0;
}

As I understand it: In the above code, in *ptr++ expression, both * and ++ have same precedence and operation will take place from right to left, which means pointer will increment first and deference will happen next. So it should print the character 'e' in the first printf statement. But it is not.

So my question is: Where will it store the incremented value (in, *ptr++) if it is not dereferencing that location in first printf statement?

  • 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-16T04:13:57+00:00Added an answer on June 16, 2026 at 4:13 am

    ptr++ means “increment ptr, but return the pre-increment value.”

    Thus despite the fact that the increment happens first, it is the original, non-incremented pointer that is being dereferenced.

    By contrast, if your precedence reasoning is correct, *++ptr should print e as you expect. ++ptr means “increment ptr and return the post-increment value”.

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

Sidebar

Related Questions

#include<stdio.h> int main() { char a[5]=hello; puts(a); //prints hello } Why does the code
#include <stdio.h> void wrapperPrint(char* s) { printf(s); return; } int main() { wrapperPrint(Hello world\n);
#include <stdio.h> int main(void){ char x [] = hello world.; printf(%s \n, &x[0]); return
#include<stdio.h> #include<stdlib.h> char* re() { char *p = hello; return p; } int main()
I just saw this here #include <stdio.h> int main(int argc, char *argv[printf(Hello, world!\n)]) {}
This part of my code works fine: #include <stdio.h> int main(){ //char somestring[3] =
I wrote a small Hello World app. #include <stdio.h> int main(int argc, const char
#include<stdio.h> #include<string.h> int main() { unsigned char *s; unsigned char a[30]=Hello world welcome; memcpy(s,&a,15);
#include < stdio.h > int main() { char *s; s=call(); printf(s); } char* call()
#include<string.h> #include<stdio.h> int main() { char *p; strcpy(p,hello world); } Well,Does it show undefined

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.