problemset_sol1

problemset_sol1 - CS211: Homework Problem Set 1 SOLUTIONS...

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

View Full Document Right Arrow Icon
CS211: Homework Problem Set 1 SOLUTIONS Assumptions: For all of these problems you may assume the following • sizeof(int) = 4; sizeof(short) = 2; sizeof(char) = 1; all pointers require 4 bytes • The stack starts at address 100 and grows up. • The heap starts at address 400 and grows up. • ??? represents an unknown/unitialized value. Question 1 : Given the following declarations: char c = ’A’; char * p = &c; char ** p2 = &p; void * v = &p2; Examine each of the following expressions. If the expression is illegal, write ILLEGAL. If the expression is legal, write its type (i.e. int ** or unsigned long\ etc): Answer: • p2[2] char * • p + 4 char * • v[4] ILLEGAL Question 2: There is an old C programmer’s joke which goes as follows: Two strings walk into a bar. The first one says “Hi I’d like a beer.A2%asd$ASDlk2;3423Ammm.234ASDfmmlASDFLJ:#@$” The second says “You’ll have to pardon my friend, he’s not null terminated.” Explain the joke. Answer:
Background image of page 1

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

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

This document was uploaded on 10/31/2011 for the course 198 211 at Rutgers.

Page1 / 4

problemset_sol1 - CS211: Homework Problem Set 1 SOLUTIONS...

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