computerese
asked on
Help decipher C++ Code Fragment
I came across the following C++ code snippet on the Internet and have been struggling to decipher what it displays. So far, I have determined that some of the numbers it displays are 5 and 8. Can someone please help me with the rest; I don't think it displays more than 4 or 5 numbers?
Thanks.
-------------------------- ---------- --C++ CODE FRAGMENT------------------ ---------- ---------- --
#include<iostream.h>
#include<stdlib.h>
#include<string.h>
struct A { int st; int d; int r; };
int main (void)
{
A a={5, 5, 5}, b={4, 4, 4}, *c=&a;
c->st =99; a.d += b.r; int & m = c->d;
cout <<--a.st;
cout << a.d--;
cout << c->r;
cout << m;
cout << (b.d + 4);
return 0;
}
Thanks.
--------------------------
#include<iostream.h>
#include<stdlib.h>
#include<string.h>
struct A { int st; int d; int r; };
int main (void)
{
A a={5, 5, 5}, b={4, 4, 4}, *c=&a;
c->st =99; a.d += b.r; int & m = c->d;
cout <<--a.st;
cout << a.d--;
cout << c->r;
cout << m;
cout << (b.d + 4);
return 0;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your timely replies. This was something I found on a website so I don't know how it was originally used. I was trying to understand it without compiling it; I was aware that I could have compiled it and it would have been interesting to see the results. But your explanations provided the "insight" into what was happening, which is what I really needed most.