# Thread: Code questions.... Need Epic Help

1. ## Code questions.... Need Epic Help

If anyone can assist I would be the most grateful person ever. I working with a programming book to learn and I have reached a standstill in the area of arrays and pointers... Thank you sooo very much in advance. These are the questions that I am attempting to answer:

For each of the following, write a single statement that performs the indicated task. Assume that long integer variables value1 and value2 have been defines and that value 1 has been initialized to 200000.
a. Define the variable lPtr to be a pointer to an object of type long.
b. Assign the address of variable value1 to pointer variable lPtr.
c. Print the value of the object pointed to by lPtr.
d. Assign the value of the object pointed to by lPtr to variable value2.
e. Print the value of value2.
f. Print the address of value1.
g. Print the address stored in lptr. Is the value printed the same as the address of value1?
Write a printf of scanf statement for each of the following:
a. Print unsigned integer 40000 left justified in a 15-digit field with 8 digits.
c. Print 200 with and without a sign.
d. Print 100 in hexadecimal form preceded by 0x.
e. Read characters into array s until the letter p is encountered.

Thanks once again,
ThatGuy

2. What have you already coded, and why isn't it working?

3. I've coded a lot up to this point but just can grasp it.

4. Did you read about arrays and pointers before trying answering those questions? If you did and still don't get it, then try reading it again. Maybe search some online tutorial and read the part on pointers.

5. Simply put, there are only really two thing to remember when working with pointers

& is 'the address of', the physical location in memory where something is stored.
* is 'the contents of', the value of the variable held at a memory location.

Making a pointer is done like:
Code:
`int *i;`
This is because *i (read as 'the contents of the pointer i') is an integer.
Setting a pointer is simple too:
Code:
```int i, *j;
j = &i;  /* j equals the address of i */```
You can manipulate the value held within a pointer location like:
Code:
```int i, *j;
j = &i;  /* j equals the address of i */
*j = 5; /* Set the contents of j (the value of i) to 5 */
if (i == *j) { /* Always True, both equal 5 */ }```
Once you have mastered this, pointer become much easier...