Hi,
I've got an assignment at school that I would really like help with. I'm a total newbie.
#include <iostream>
using namespace std;
int main()
{
char chr=(char)67;
unsigned int offset = 1000;
char * ptr=(char*)0;
ptr+=offset;
cout
<< ptr[0]
<< (char)43
<< (char)(chr-24)
<< endl;
}
The questions I'm gonna answer is:
1. Compile and run the program. What's happening? Can you explain why?
2. In the program, it's defined an integer like this: unsigned int offset = 1000;
By changing the line to unsigned int offset =(unsigned int)&chr;
the program will work. Please explain what the new line does, and why it makes the program work.
3. Write a shorter program that gives the same output as when the program works.
4. Explain what happens, line for line in the program.
Would really appreciate some help!