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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:27:44+00:00 2026-06-15T21:27:44+00:00

Possible Duplicate: Accessing arrays by index[array] in C and C++ #include <stdio.h> int main()

  • 0

Possible Duplicate:
Accessing arrays by index[array] in C and C++

#include <stdio.h>
int main()
{       
    int a=3, b = 5;
    printf(&a["Ya!Hello! how is this? %s\n"], &b["junk/super"]);
    printf(&a["WHAT%c%c%c  %c%c  %c !\n"], 1["this"],
    2["beauty"],0["tool"],0["is"],3["sensitive"],4["CCCCCC"]);

    return 0;
}

This is one of the practice problems that I was given in class. I’m trying to figure out how this code was able to get to the output, which is

Hello! how is this? super
That is C !

The &a[” %s”] operation. How does that work? along with the seco

  • 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-15T21:27:45+00:00Added an answer on June 15, 2026 at 9:27 pm

    The code

    &a["Ya!Hello! how is this? %s\n"]
    

    Is interpreted as

    &(a["Ya!Hello! how is this? %s\n"])
    

    Since all C-style strings are pointers, this is a bizarre but legal usage of the fact that

    arr[i]
    

    and

    i[arr]
    

    are both legal in C. Consequently, the code should be interpreted as

    &("Ya!Hello! how is this? %s\n"[a])
    

    And since a = 3, this is the character H. Since we take the address of this character, this gives a pointer to the C-style string

    "Hello! how is this? %s\n"
    

    Using this as a starting point, you can try to decode the rest of the program.

    Hope this helps!

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

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Is the “struct hack” technically undefined behavior? Normally accessing an array beyond
Possible Duplicate: Accessing the index in Python for loops I wonder: does Python have
Possible Duplicate: jQuery/JavaScript: accessing contents of an iframe If i run this on my
Possible Duplicate: array_splice() for associative arrays How to add an array value to the
Possible Duplicate: Problem accessing user uploaded video in temporary memory So I've tried this
Possible Duplicate: Accessing inherited variable from templated parent class There's this class: template<typename T>
Possible Duplicate: && operator in Javascript In the sample code of the ExtJS web
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:

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.