home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!news.hawaii.edu!stego!yamada
- From: yamada@stego.ifa.hawaii.edu (Hubert Yamada)
- Subject: Re: Updated and improved "testing competence" questions
- Message-ID: <1992Dec13.083731.15395@news.Hawaii.Edu>
- Sender: root@news.Hawaii.Edu (News Service)
- Nntp-Posting-Host: stego.ifa.hawaii.edu
- Organization: University of Hawaii, Institute for Astronomy
- References: <1gbstkINNfcp@almaak.usc.edu>
- Date: Sun, 13 Dec 1992 08:37:31 GMT
- Lines: 38
-
- In article <1gbstkINNfcp@almaak.usc.edu> ajayshah@almaak.usc.edu (Ajay Shah) writes:
- >7. There is a C program which contains the line
- >
- >#include "min.h"
- >
- > Now min.h EITHER contains
- > #define min(a, b) (a)<(b)?(a):(b)
- > OR
- > int min(int a, int b);
- > but you don't know which.
- >
- > Write a test program which will tell you what is in min.h
- > You are not allowed to know anything about how your program is linked;
- > you are only allowed to write this program, and see it's behaviour in
- > compilation and execution.
-
- I really wonder what this question is trying to test. If you're trying
- to see if your applicant knows about the danger of side effects when
- macro has arguments, then why not just ask the more straight forward
- question:
-
- Given:
- #define MIN(a,b) ((a) < (b) ? (a) : (b))
- int min(int a, int b) { return MIN(a, b); }
-
- What are the differences between using MIN() and using min()? Is
- there any time when you could use one, but not the other?
-
- I think that a valid answer to _your_ question would be: who cares
- whether it's the macro or the function? If I was that unsure about a
- function that I had to use, I would either reimplement it, find a
- suitable replacement, find the documentation, or write code that would
- work correctly in either case.
- --
- Hubert Yamada * Our hero is called before the alien
- yamada@galileo.ifa.hawaii.edu * potentate! Where it becomes clear that
- yamada@uhunix.uhcc.hawaii.edu * Spiff is about to be sacrificed to appease
- Bitnet: yamada@uhunix.bitnet * the evil god they call "Nollij"!
-