# Web Development

## General discussion

Locked

### C Lang - Pointer

By ·
Pls help me to see if I have answer correctly.
If my answer is wrong, pls help to explain
- James

char first=?w?, second; /* ASCII value of ?w? is 119 */
char *pfirst, *psecond = &second; /* question (b) */

*psecond = first + 10;
first = second + 1; /* question (c) */
pfirst = &first; /* question (d) */

Suppose each character occupies 1 byte of memory. If the value assigned to first is stored in address 1200 and the value assigned to second is stored in address 1201, then

a)What value is represented by &second ?

b)What value is assigned to psecond ?

c)What value is assigned to first ?

d)What value is assigned to pfirst ?

e)What value is represented by (100 + *pfirst)?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

Collapse -

### C Lang - Pointer

by In reply to C Lang - Pointer

It looks like second is not assigned anything when you define it and you start using it with nothing defined.

Collapse -

### C Lang - Pointer

by In reply to C Lang - Pointer

Collapse -

### C Lang - Pointer

by In reply to C Lang - Pointer

Hi,
I will go by questions and explain..
A) Correct
B) 1201 --- psecond contains the address of second (psecond=&second)
C) 130 ---
*psecond = first + 10; /* here second is set to 129) */
first = second + 1; /* Here first is set to 130 */
D) 1200 --- pfirst contains the address of first (pfirst = &first)
E) 230 --- (100 + *pfirst) See C) - there first is set to 130

P.S.
*somepointer means the value pointed by somepointer

P.P.S.
char *pfirst, *psecond = &second;
here is not set the value pointed by psecond but the pointer itself
this is equal to:
char *psecond;
psecond = &second;
not to:
char *psecond;
*psecond=&second;//this is wrong

Collapse -

### C Lang - Pointer

by In reply to C Lang - Pointer

Collapse -

### C Lang - Pointer

by In reply to C Lang - Pointer

This question was closed by the author

## Related Discussions

• 12

• 23

• 1

#### Best Framework for Web Developement?

iftikharqureshi ·

• 5

inextures ·

• 10

#### Best software to design Simple Website?

matthewjohn938 ·