Results 1 to 2 of 2

Thread: C lang - Pointer

  1. #1
    Member
    Join Date
    Jan 2000
    Posts
    57

    C lang - Pointer

    Pls help me to see if I have answer correctly. - 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 ?
    ANSWER : 1201

    b)What value is assigned to psecond ?
    ANSWER : 120

    c)What value is assigned to first ?
    ANSWER : 129

    d)What value is assigned to pfirst ?
    ANSWER : 130

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

  2. #2
    Junior Member
    Join Date
    Oct 2001
    Location
    NM USA
    Posts
    5
    After the first five lines, the values are:

    &first == 1200
    &second == 1201
    first == 130
    second == 129

    psecond == 1201
    pfirst == 1200

    Answers are:
    a) 1201
    b) 1201
    c) 130
    d) 1200
    e) 230

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •