🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2506

Re: What are some tricky C questions?

#2506
From: Lawrence Kirby
Date: Fri, 05 Apr 1996 00:31
36 lines
1716 bytes
In article <4jttdi$3jm@solutions.solon.com>
           jkb@mrc-lmb.cam.ac.uk "James Bonfield" writes:

>In article <4jol5v$1qs@solutions.solon.com> wawda@chaph.usc.edu (Abu Wawda)
> writes:
>>After reading the thread on "Good C interview questions", I've got to
>>ask people to post some tricky/trivia questions on programming in C or
>>even programming in general. Does anyone have any? Thanks in advance.
>
>How about explaining what following construct does. What can be said about the
>values of l and i at the end?
>
>    size_t l;
>    int i = MAXINT;
>
>    l = sizeof(++i);
>
>:-)

Very little since MAXINT isn't defined. :-) Perhaps if you were to include
limits.h and use INT_MAX instead. If you want to add a bit of interest to
the problem you could ask the same question about:

#include <stddef.h>
#include <limits.h>

    size_t l;
    short i = SHRT_MAX;

    l = sizeof(++i);

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Technical Details
Message-ID: <4k1pks$514@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4jol5v$1qs@solutions.solon.com> <4jttdi$3jm@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: Lawrence Kirby <fred@genesis.demon.co.uk>
Newsgroups: comp.lang.c.moderated
Subject: Re: What are some tricky C questions?
Date: 4 Apr 1996 18:31:24 -0600
Organization: none
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4k1pks$514@solutions.solon.com>
References: <4jol5v$1qs@solutions.solon.com> <4jttdi$3jm@solutions.solon.com>
Reply-To: fred@genesis.demon.co.uk
NNTP-Posting-Host: solutions.solon.com
X-NNTP-Posting-Host: genesis.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.27
X-Mail2News-Path: genesis.demon.co.uk