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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:58:22+00:00 2026-06-10T01:58:22+00:00

Hi all can someone please tell me what does this line of code do

  • 0

Hi all can someone please tell me what does this line of code do

xdata.yarray[3] = *(ptr++);  
xdata.yarray[2] = *(ptr++);  
xdata.yarray[1] = *(ptr++);  
xdata.yarray[0] = *(ptr++);  

I am trying to figure out someone Else’s code so having problems
would also appreciate if anyone could offer some useful pointers on the best way to decipher someone Else’s code.

Thank you

would the meaning of the code be changed if instead of xdata it was just data

  • 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-10T01:58:24+00:00Added an answer on June 10, 2026 at 1:58 am

    You have plenty of answers as to what this code does. Presumably, coping the contents of some array pointed to by ptr and storing it in reverse order to another array contained within the struct “xdata”.

    You asked how you could decipher this on your own, which is an excellent question, best way to learn is to do it yourself. Here’s my advice: take what you know, create your own little program based on that, and view the output.

    For example, without seeing all of the code, I know you have an array “yarray” of 4 elements, and you’re storing values from a dereferenced pointer in to it. You could make a little program like below to see how the code reacts:

    void main()
    {
        int yarray[4] = {0, 0, 0, 0};
        int my_array[4] = {1, 2, 3, 4};
        int *ptr = my_array;
        int cntr;
    
        for(cntr = 0; cntr < 4; cntr++)
            printf("then: my_array = %d, and yarray = %d\n", my_array[cntr], yarray[cntr]);
    
        //Add the code that you're not sure what it does here...
        yarray[3] = *(ptr++);
        yarray[2] = *(ptr++);
        yarray[1] = *(ptr++);
        yarray[0] = *(ptr++);
    
        //Check out the results!
        for(cntr = 0; cntr < 4; cntr++)
            printf("now: my_array = %d, and yarray = %d\n", my_array[cntr], yarray[cntr]);
    }
    

    Now you can see that the code is reversing the order of the contents that ptr is pointing to and storing it in the yarray.

    then: my_array= 1, and yarray = 0
    then: my_array= 2, and yarray = 0
    then: my_array= 3, and yarray = 0
    then: my_array= 4, and yarray = 0
    
    now:  my_array= 1, and yarray = 4
    now:  my_array= 2, and yarray = 3
    now:  my_array= 3, and yarray = 2
    now:  my_array= 4, and yarray = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone tell me why this processes all the files and then does it
Can someone please tell me where I'm going wrong with this piece of code?
Can someone please tell me how to show all privileges/rules from a specific user
Can someone please tell me where these extra characters are coming from? This is
Hie Can someone please tell me how to fetch all the feeds of a
Can someone please tell me how to find out the pathname of the KornShell
Can someone please tell me why this wont work? I am getting error preg_match_all():
Can someone please tell me why this header wont go straight across? My goal
Can someone PLEASE tell me why the below code is searching for sub folders
the question says it all. Can someone please tell me if that is possible

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.