spring 2013 exam 2

O baro gcc o hello fooo baro fooo fooc firsth

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: as they are declared in the source code). Write a short c function to detect whether the stack grows downwards or upwards. The function needs to return 0 when it’s downwards, and 1 otherwise. Hint: you need to find two separate items on the stack, and compare their addresses to answer this question. According to item 4 above, you cannot use two local variables in a function since their allocation is in a random order. int * foo (){ int i; return &i; } int direction() { int j, *k; k = foo(); if( (long) &j > (long) k ) return 0; else return 1; } 3/6 Question 2 makefile (9 pts) Suppose we have the following makefile: =================== all: hello hello: f...
View Full Document

Ask a homework question - tutors are online