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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:29:02+00:00 2026-06-06T06:29:02+00:00

#include<stdio.h> int main() { char *s[] = { knowledge,is,power}; char **p; p = s;

  • 0
#include<stdio.h>
int main()
{
    char *s[] = { "knowledge","is","power"};
    char **p;
    p = s;
    printf("%s ", ++*p);
    printf("%s ", *p++);
    printf("%s ", ++*p);

    return 0;
}

Output:

nowledge nowledge s

Please explain the output specially output from the 2nd printf() statement.I think that because ++ and * have same precedence therefore in *p++ p should be incremented first and then use *(associativity from right to left for unary operators).

  • 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-06T06:29:05+00:00Added an answer on June 6, 2026 at 6:29 am

    According to C++ Operator Precedence:

    1. “*” has the same precedence as prefix “++” but must be avaluated rigth to left.

      printf(“%s “, ++*p);

    So first *p is evaluated, then ++(*p), leading to the second character in the first string.

    1. “*” has less precedence than suffix “++”.

      printf(“%s “, *p++);

    So first p is incremented, but it is a post-increment. The value returned from the operation is the original one. This way, the * operates over the original pointer, that pointed to the second char on the first string.

    Note that, this time, ++ is operating over p, and not over *p.

    1. Since “2”, p points to the second string. When you do ++*p you are now pointing to the second character of the second string (“s”). As you are again using a pre-increment, the value passed to printf is already changed.

      printf(“%s “, ++*p);

    I may get clearer if you do a little change and print the pointer value aswell (ignore the warnings):

    printf("%s [%p]\n", ++*p, p );
    printf("%s [%p]\n ", *p++, p );
    printf("%s [%p]\n ", ++*p, p );
    
    nowledge [0x7fff6f5519e0]
    nowledge [0x7fff6f5519e8]
     s [0x7fff6f5519e8]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <stdio.h> #include <stdlib.h> int main() { char *str=Helloworld; printf(%d,printf(%s,str)); return 0; } output
#include<stdio.h> int main() { char a='x'; printf(%c %d,a); return 0; } Output: x 134513696
#include<stdio.h> int main() { char a, b; scanf(%c, &a); scanf(%c, &b); printf(%c %c,a,b); return
#include <stdio.h> int main() { char temp[1024]; if(getchar() != 'y') { printf(no options\n); return
#include<stdio.h> #include<string.h> int main() { char a[]=aaa; char *b=bbb; strcpy(a,cc); printf(%s,a); strcpy(b,dd); printf(%s,b); return
#include <stdio.h> int main() { char TurHare; while(1) { scanf(%c,TurHare); printf(\nCharacter :%c, TurHare); }
#include<stdio.h> #include<ctype.h> int main() { char a,b; FILE *fp; fp=fopen(lext.txt,w); fprintf(fp,PLUS); return 0; }
#include<stdio.h> int main() { char *p=mystring; return 0; } String literal mystring, where will
#include <stdio.h> int main () { char loop='y'; while(loop != 'n') { printf(loop? );
#include<stdio.h> int main(){ char a[6],*p; a[0]='a'; a[1]='b'; a[2]='c'; a[3]='4'; a[4]='e'; a[5]='p'; a[6]='f'; a[7]='e'; printf(%s\n,a);

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.