homework6 - Answer : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework 6 Problem 1: Given a structure named “ Node , and “ Next is a field of the Node structure. Like this: If there is an object of Node named MyNode and the address of the Next field is known. Can you given a C expression which can calculate the address of MyNode ? ( NOTE: you can just use the address of the Next field . Next ) ) Problem 2: Consider the following C declaration: Using the templates below (allowing a maximum of 28 bytes), indicate the allocation of data for structs of type data_t . Mark off and label the areas for each individual element. Cross hatch the parts that are allocated, but not used, and be sure to clearly indicate the end of the structure. Assume the Linux alignment rules discussed in class.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Answer : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 Struct Node{ ... Struct Node *Next; ... }; typedef struct data_s { short start; double len; double *real_data; short end; struct data_s *next; } data_t; Problem 3: Please answer the following questions, assuming sizeof(int)=4, sizeof(long)=4: A. Given a piece of C code: What’s the value of variable n? Answer : B. Given a piece of C code: What result will be printed out? Answer : int a[20]; char * p1 = (char *)a; char * p2 = (char *)(a+5); int n= p2 ‐ p1; char * p = “ helloics ” , *r; long *q; q=(long* )p; q++; r=(char *)q; printf("%s\n", r);...
View Full Document

This note was uploaded on 10/19/2011 for the course CS 000 taught by Professor Jing during the Fall '10 term at Fudan University.

Page1 / 2

homework6 - Answer : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online