HDTenEightyP/NetNews huggingface dataset:
From: wells@cdsmn.mn.org (Rich Wells)
Subject: a ? b : c = d; /* legal ? */
Summary: interpretation question re conditional operator
Keywords: interpretation, conditional operator, language issue
Organization: Dicomed, Inc
X-Newsreader: TIN [version 1.1 PL6]
Date: Wed, 16 Dec 1992 19:29:17 GMT

Is the statement:

    a ? b : c = d;

where a, b, c, and d are all integers, a valid C expression?
I suspect not, since precedence rules determine that the
statement is equivalent to

    (a ? b : c) = d;

and since the ?: operator does not yield an lvalue, the
expression is flawed.

The above argument is based on the book _ANSI C: A Lexical
Guide_, a not entirely unimpeachable source, so I thought
I'd consult the net.wisdom for the correct answer.

Also, the three compilers I have experimented with each have
different interpretations.  To wit:

***** Microsoft C (7.0 and 5.1):

The statement does not compile.  The compiler complains
(rightly, I think) that the ?: does not yield an lvalue,
and so the assignment is invalid.

***** Metaware HighC (version 3.01 for the 386):

The statement is interpreted as:

    if (a)
        b;
    else
        c = d;

which, it seems to me, ignores precedence rules.

***** Turbo C++ (3.0):

The statement is interpretted as:

    if (a)
        a = d;
    else
        b = d;

In other words, it allows the ?: operator to yield an
lvalue, and uses that for the assignment.  (NOTE: TC++
is a C++ compiler; does this change the answer?)

*****

So that I don't have to go out and buy an asbestos suit, I
want to make it very clear that I would never even consider
writing code like this.  This came from a friend of a friend
(perhaps I should post to alt.folklore.computers?) who claims
he was asked this on an employment exam, and was told that
the Turbo C++ interpretation is correct.

BTW: if I have used the words 'statement', 'expression' and
'lvalue' wrong, forgive me; I'm not an experienced language
lawyer.  However, please correct me if I used them wrong;
inquiring minds want to know.
-- 

Richard Wells  wells@cdsmn.mn.org  or  ...!tcnet!cdsmn!wells
Newsgroups: comp.lang.c
From: jjunker@sdf.lonestar.org (Jon Junker)
Subject: Need HELP with strptime....any answers/clues?????
Organization: sdf full-shell Public Access Unix - Dallas, TX - 214/436-3281
Date: Wed, 16 Dec 1992 22:58:57 GMT

Hi:
 
I have been working with some of the time functions (on a Sun
SPARCstation IPX).  After I make a call to strptime (to fill 
in the tm structure) I display the structure (with dbxtool) and
find that the structure is filled in incorrectly.  What am I 
doing wrong?
 
Please, e-mail me with the answer. Below is some example code.
 
Thanks for your time,
Jon
jjunker@sdf.lonestar.org
 
 
        ---------- Example Call to AsciiToTime ----------
				:
				:
				:
	timeStatus = AsciiToTime("1990,123/065301.123");
				:
				:
				:
 
        ---------- Module and Call in Question ----------

#include	<time.h>
 
AsciiToTime(timeString)
char	*timeString;
{
	struct	tm	*my_tm;
 
	/* Convert time string into the time structure (my_tm) */
	(void)strptime(timeString,"%Y,%j/%H%M%S",my_tm);
 
/* ---> After the above call to strptime the tm structure is not filled
	in correctly. What am I doing wrong ??????
*/
 
	return(0);
}
Newsgroups: comp.lang.c
From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
Subject: Re: Question to test general C knowledge
Reply-To: volpe@ausable.crd.ge.com
Organization: GE Corporate Research & Development
Date: Sun, 13 Dec 1992 05:14:42 GMT

In article <1992Dec12.230520.771@thunder.mcrcim.mcgill.edu>, mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
|> In article <1992Dec11.180939.20726@crd.ge.com>, volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe) writes:
|> >                                                ^^^^^^^^^^^^
|> > Why?
|> 
|> Based on a sequence like
|> 
|>         ! compute needed values
|>         addl3   _i,$1,r0        ! compute value of ++i
|>         ! sequence point; do accumulated side-effects
|>         movl    r0,_i           ! store value of ++i into i
|>         incl    _i              ! increment i
|> 
|> Thus we see the wisdom of ANSI's rule :-)

Umm. I question whether it would be legal for the compiler to emit
such code. The reason is that the value of the "++i" expression is
"the value of i after the assignment". The first assembly statement
computes this value as "3". However, the "value of i after the assignment"
is determined by the result of the "incl _i" statement, and that 
value is 4, which contradicts the definition of the value of the "++i"
expression. 

-Chris

-- 
==================
Chris Volpe
G.E. Corporate R&D
volpecr@crd.ge.com
From: dik@cwi.nl (Dik T. Winter)
Newsgroups: comp.lang.c
Subject: Re: *graceful* number series
Date: 17 Dec 92 22:21:29 GMT
Organization: CWI, Amsterdam

In article <102419@netnews.upenn.edu> yates@a.chem.upenn.edu (John H. Yates) writes:
 > I have a user that has a bad C code for generating
 > graceful numbers. Does anyone have such a beast
 > or a reference? I can't explain what a graceful
 > number is, but it is evidently a mathematically
 > accepted and defined beast.
I think these are Ullams graceful numbers.  The definition is by a
process similar to Eratostenes sieve method for primes, although I do
not remember the exact detail.  If I am right Martin Gardner once
featured them in one of his columns (but this is quite a few years
ago, like the sixties).  You might also look in the books by Martin
Gardner, I am quite sure in one of those books is a reference to them.
But being 'mathematically accepted', I would not know.  Try sci.math.
-- 
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland
home: bovenover 215, 1025 jn  amsterdam, nederland; e-mail: dik@cwi.nl
From: billb@crpmks.uucp (Bill Bochnik (Info Systems))
Newsgroups: comp.lang.c
Subject: Re: What do you say.
Date: 11 Dec 92 18:20:43 GMT
Reply-To: billb@crpmks.UUCP (Bill Bochnik (Info Systems))
Organization: Ciba-Geigy Corporation

In article <2880.imc@uk.ac.ox.prg> imc@comlab.ox.ac.uk (Ian Collier) writes:
>In article <Byx8I7.9K5@umassd.edu>, muftring@cis.umassd.edu (Michael D. Uftring) wrote:
>>>   Here's a question for you.  What do you say to a co-worker who
>>>   asks you "What is the difference between equals and equals equals?"
>
>>Yeah, maybe something like: "... either the're equal or REALLY equal ..."  :)
>
>Don't laugh - it's true ...
>
>... in REXX, where 0.0 and 0 are equal, but they aren't "REALLY equal".
>
>Who said the guy was talking about C?  :-)
>
>Ian Collier
>Ian.Collier@prg.ox.ac.uk | imc@ecs.ox.ac.uk

The original post did (:-))





-- 
Bill Bochnik			| It's hard to be a James Bond in an Abbott
Systems Analyst 		|	and Costello world.
Ciba-Geigy Corporation		| Signed and sealed, they deliver oblivion.
philabs!crpmks!billb		| It's worse than that, he's dead Jim.
Newsgroups: comp.lang.c,comp.unix.xenix.sco
From: johnson@ecsvax.uncecs.edu (Patti Johnson)
Subject: help with scripts vs. programs (compiled)
Followup-To: poster
Keywords: shell scripts, compiled programs
Organization: UNC Educational Computing Service
Date: Thu, 17 Dec 1992 18:23:24 GMT


Can anybody tell me the difference between shell scripts and compiled
programs?  Here's the trouble:
 
I have a program that opens a pipe for reading... the pipe executes
a command, the last line of which is what the program needs for internal
use.  So far, so good.  If this program opens a pipe that calls a shell
script, everything's a-okay.  If this program opens a pipe that calls
a compiled (C language) program, it's not: prompts displayed by the
called routine (ie the pipe opened for reading) are delayed until AFTER
the data has been entered (a lotta good that does).
 
Here's one thing I've noticed:  I tried running ps -ft on that port in
the background, saving the output.  When a shell script is called, two
lines are displayed, both beginning with "sh -c", which is followed by
the command/routine.  When a program is called, two lines are displayed
for that command/routine, only the first, parent process, has the "sh -c"
prefix.  That's the ONLY difference I can find... must be somewhere in
there.
 
If anybody has any ideas, please reply to my mailbox: johnson@micronet.wcu.edu
and I'd be happy to report any summary to the interested.
 
			patti
Newsgroups: comp.lang.c
From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
Subject: Re: Problems with Case statements HELP!
Keywords: case help lost c not
Organization: Texas Instruments Inc
Distribution: usa
Date: Tue, 15 Dec 1992 17:23:51 GMT

In <Bz18KA.MCv@access.digex.com> jhurwitz@access.digex.com (j. hurwitz) writes:


>Okay, I'm new to C so you'll have to forgive my lame question. Anyhoot,
>I'm trying to write a program that will check for balanced braces in my
>C source code. I have no problem when I do this:

>=========================== Begin Hack =============================
>//programm to read a C source file and verify # of left to right braces

>But, when I try this:

>============================== Begin Hack =========================
>//programm to read a C source file and verify # of left to right braces

>#include <stdio.h>
>int main(int argc, char *argv[])
>{
>   FILE *fptr;
>   int l=0, r=0;
>   char ch;

>   fptr  = fopen("brachek3.c","r");
>   while ((ch =getc(fptr)) !=EOF)      
>   {
>   switch (ch)
>     {
>     case '{':  l++; 
                        <<---- fall through case.
>     case '}':  r++; 
>     }
>   }
>   printf("\nl= %d r= %d", l, r);
>   if (l != r)
>   printf("\nBraces do not match\n");
>   else printf("\nBrace match !!!\n");
>   fclose(fptr);
>}
>================================ End Hack ========================
>I get an uneven number of braces at the end. I can't figure out what
>I am doing wrong. I'm sure it is a minor oversight on my part. Any help
>would be greatly appreciated

In C, each case is simply a label and will fall through to the end of
the switch unless it encounters a 'break' statement to end it.  Each
time you find a '{' you are incrementing both r and l.  Each time you
find a '}' you are incrementing only r.  Given the code, r will exceed
l by the number of '}' characters you find.  If things are balanced,
it will be twice l.

Your switch should read:

	switch (ch) {
	   case '{':
	      l++;
	      break;
	   case '}':
	      l++;
	      break;
	   default:
	      /* Do nothing */
	      break;
	}

A lot of people think that including the empty default (or putting a
break on the default case, period) is a bit anal retentive, so handle
it however you are comfortable.

-- 
"Insisting on perfect safety is for people who don't have the balls to live
 in the real world."   -- Mary Shafer, NASA Ames Dryden
------------------------------------------------------------------------------
Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
Xref: sparky comp.lang.c:18614 comp.unix.bsd:10370
From: canalda@minos.inria.fr
Newsgroups: comp.lang.c,comp.unix.bsd
Subject: Re: Segmentation faults
Date: 18 Dec 92 15:23:17 GMT
Reply-To: canalda@minos.inria.fr
Followup-To: comp.lang.c
Organization: Institut National de Recherche en Informatique et Automatique (INRIA)


	Hi,
In order to answer to the 37231th article in comp.lang.c group, I rewrite some
part of the initial article.

>void end()
>{
>   printf("\33[?25h"); /*BTW what does this do with an ANSI terminal?*/
>}
>
>int main()
>{  /*This code is for testing the above for use with terminals*/
>  char s[80];
>  int x,y;
>  start1(); 
>  start2();
>  do{
>     writexy(1,1,"enter x y string:");
>     scanf("%d%d%s",&x,&y,s);
>     writexy(x,y,s);
>  } while(s[0]!='#');
>  end();
>  return 0; 
>}
In this program the declaration of end() is ambiguous because it also refers to
standard routines :

extern end; This name refers neither to routines nor to locations  with
interesting  contents. The address of end() is the first address above the
uninitialized data region.

When execution begins, the program break (the first location beyond  the data)
coincides with end, but it is reset by the routines brk, malloc, standard
input/output and so on.

So a simple solution would be to change the name of your eeeeeennnnnnnnnddddddd.

Good receive.

#########################################################################
#   _______    __               ______    email : canalda@minos.inria.fr#
# /______ /| /_ /|            /_____ /|   address:    I.N.R.I.A.        #
#|   __  | ||  | |___        |   ___|/           Dommaine de Voluceau   #
#|  |/_) | ||  |/___ /|      |  | |              Rocquencourt B.P.105   #
#|   ____|/ |   __  | |   __ |  | |___    __     78153 LeChesnayCedex   #
#|  | |     |  | || | | /_ /||  |/__ /| /_ /|           FRANCE          #
#|__|/      |__|/ |_|/ |__|/ |______|/ |__|/  tel: +33 (1) 39 63 53 61  #
#########################################################################
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: longjumping out of a signal handler
Date: 16 Dec 92 14:35:24 GMT
Organization: AND Software BV Rotterdam

In article <1992Dec14.223422.39678@spillman.uucp> tye@spillman.uucp (E. Tye McQueen) writes:
|ahoekstr@cs.utwente.nl (Andre D. Hoekstra) writes:
|)But if your implementation of signal handlers blocks overrun signals by
|)setting a flag on entry in your signal handler, and clearing it on exit,
|)you may get stuck with a masked signal, by not exiting from the handler.
|)(longjump prevents exit/return obviously). Unless signal clears this
|)flag for the signal at hand explicitly you are unsafe.

|Well, it is nice to know that some (pre-ANSI?) system have this
|problem.  Anyone have a list of *which* systems have this problem?

I was the one who advised Andre not to use a longjump from within a
signal function. I should have stated explicitely that longjmp can 
fail in _pre_ ANSI C systems (my own experience.) The ANSI C standard
indeed guarantees that a longjump will work from within a signal
function.

|K&R II doesn't talk about any of this and my copy of the standard
|is way outdated, so maybe I'm wrong; but I distinctly recall that
|ANSI guarantees only two things that can be done within a signal
|handler:  1) Set a variable of type "sig_atomic_t"  and  2) Call
|longjump().

There are two other functions that are guaranteed to work are:
abort() and exit().

|If so, how do such systems conform to ANSI C?  Does setjump() save
|the signal mask and longjump() restores it?  Is there some require-
|ment that I reset the signal myself from within the handler before
|calling longjump()?  Or is this just an OS "bug" that newer systems
|no longer have?  (I mean, longjump(), if anything, is for exception
|handling as are signals so it doesn't make sense to design a system
|where they can't be used together.)

True, all true, as far as I can find in the ANSI C standard, it's
perfectly safe now to use longjmp() from within a signal function.
No special prerequisites are necessary ...

|I'm not arguing that using longjump() within a signal handler is in
|fact safe on all systems.  It clearly is not.  But I don't think
|setting a global flag in the signal handler and checking it in a
|calling routine will work on all systems either (see below).
|
|Anyone know which systems restart system calls for you in a way that
|prevents you from interrupting them with a caught signal so you can
|see if your "sig_atomic_t" flag has been set?  Seems like this was a
|BSDism.  Is this behavior disallowed by ANSI C, Posix, etc.?

Count me out here, I don't know the answer to that one, sorry.

kind regards,

Jos aka jos@and.nl
From: CHT002@DJUKFA11.BITNET
Newsgroups: comp.lang.c
Subject: How to subscribe ?
Date: 15 Dec 92 15:54:19 GMT
Organization: Forschungszentrum Juelich

Hi everibody !

A frend of mine would like to read the comp.lang.c newsgroup but he has
no access to a netnews server. The question is can he subscribe to some
mail list to get the news by e-mail? The second question is to what e-mail
adress should he post his articles to appear in the comp.lang.c?

Please do not answer to me, but directly to Erne Jonas at:

erne%vector@autodesk.com

Many thanks for your help,
J.J. Comor
Newsgroups: comp.lang.c
Subject: TSR and resident programs .
From: rodnay@chen.bgu.ac.il (guy rodnay )
Date: Sun, 13 Dec 1992 15:56:51 GMT
Organization: Ben Gurion University, Beer Sheva, Israelwould very much apreciate any help
 on TSR's and other Memory -Resident programs (sources , if possible ).

		Thanks in advance ,

				Zac p.


--
NAME Zac Pickholtz
EMAIL eacu158@menix.bgu.ac.il
Newsgroups: comp.lang.c
From: etljmme@etlxd30.ericsson.se (Jim)
Subject: Re: How to test a programmer
 
Reply-To: etljmme@etlxd30.ericsson.se
Organization: Ericsson Telecom AB
Date: Wed, 16 Dec 1992 16:51:55 GMT

In article 724521723@pv0321.vincent.iastate.edu, dschmitz@iastate.edu (Daniel C Schmitz) writes:
> [stuff deleted]
>  This not only
>tested my programming skills, but my knowledge of graphics algorithms and
>my attention to details that the programmer must know but were not provided
>with the original problem description.  E.g. what is the format of the file,
>should the coins be centered top to bottom with relation to each other and/or
>to the screen.  Will the input contain errors and/or more coins than will fit
>on the screen.  What are the sizes of the coins.

This is interesting, how did you solve uncertanties like the format of the file?
The format could be almost anything!  The other problems like the size of the
coins could, I suppose, be left to aesthetics provided the requirement is 
satisfied but I can't see how to code for handling the file without prior
knowledge of the file format.  Or is the point simply that the programmer
recognises these problems?

Regards,
Jim.
Newsgroups: comp.lang.c
From: ctaylor@cs.uiuc.edu (Conrad Taylor)
Subject: What's wrong with the following code...?
Organization: University of Illinois at Urbana-Champaign
Date: Sun, 20 Dec 1992 19:11:48 GMT

         Could someone please assist me with the following code which it
to build a binary tree and print out the tree nodes?  Thanks in advance to
all that reply.

-Con

ps:  My e-mail is ctaylor@silver.lcs.mit.edu or
     taylor1@wse.eecs.uic.edu.


#include <stdio.h>
#include <stdlib.h>

struct node {
   int Info;
   struct node *LeftTree;
   struct node *RightTree;
};

typedef struct node *NODEPTR;

NODEPTR Root;

void    TreeInsert(int Number, NODEPTR Root);
void    TreeBuild(NODEPTR Root);
void    TreePrint(NODEPTR Root);




void TreeBuild(NODEPTR Root)
{
    Root = NULL;

    TreeInsert(6, Root);
    TreeInsert(4, Root);
    TreeInsert(8, Root);
    TreeInsert(7, Root);
    TreeInsert(9, Root);
    TreeInsert(5, Root);
    TreeInsert(3, Root);
} /* end TreeBuild */




void TreeInsert(int Number, NODEPTR Root)
{
    if (Root == NULL)
      {
	 Root = (NODEPTR)malloc(sizeof(struct node));
	 Root->Info  = Number;
	 Root->LeftTree = NULL;
	 Root->RightTree = NULL;
      }
    else if (Number < Root->Info)
      TreeInsert(Number, Root->LeftTree);
    else if (Number > Root->Info)
      TreeInsert(Number, Root->RightTree);
    /* else if (Number = Root->Info) */
    /*   do nothing since Number is already in the tree. */
} /* end TreeInsert */




void TreePrint(NODEPTR Root)
{
   if (Root != NULL)
     {
	TreePrint(Root->LeftTree);
	printf("%2d\n", Root->Info);
	TreePrint(Root->RightTree);
     }
}




int main(void)
{
  printf("Start the program.\n"); 
  TreeBuild(Root);
  TreePrint(Root);
  printf("Finish the program.\n"); 

  return 0;
}
From: gm08@fg30.rz.uni-karlsruhe.de (Steffani)
Newsgroups: comp.lang.c
Subject: Re: a question about if and case
Date: 15 Dec 1992 12:44:54 GMT
Organization: University of Karlsruhe, Germany
Reply-To: gm08@rz.uni-karlsruhe.de
NNTP-Posting-Host: fg30.rz.uni-karlsruhe.de

In article <Mf=CaVW00aw4QDV2dx@andrew.cmu.edu> dw3u+@andrew.cmu.edu (Daniel C. Wang) writes:
>GM08@DKAUNI2.BITNET (hans friedrich steffani) writes:
>> 
>> or is there a third way??
>> i need contructions like this very often so i need a GOOD
>> solution.
>
>The first way is more readable the second probably marginaly faster
>during compile time.  Can't think of a third way off hand that would
>be worth mentioning.  I'd stick with readablity over 'speed.'
thats the problem:
most people think that many cases with one code are bad to read.
but i think reading many if s is not better.
a aggree that readablity is more neccessary than speed.

---
hans friedrich steffani
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: Question to test general C knowledge
Date: 17 Dec 92 08:40:51 GMT
Organization: AND Software BV Rotterdam

In article <1992Dec16.180117.72534@ns1.cc.lehigh.edu> dsbb@ns1.cc.lehigh.edu (D. SPENCER BEECHER) writes:
|>>>>    int i = 2;
|>>>>    i = ++i;
|>>> If they say other than "it's undefined", *then* don't hire them.
|
|After reading much discussion on this matter, I have only
|one question:
|
|On what page of the white book does it indicate precedence in
|evaluation of the above statement?

Ok, one more time: precedence in evaluation has got nothing to do with this.
The behavior is undefined, it was undefined, it is undefined and, as far as
I can tell, it will allways be undefined. If an object changes value between
two sequence points more than once, the final result is undefined.

|I would compare this to the line:
|
|putchar(c)=getchar();
|
|(which, by the way, does NOT work on any but the most forgiving compilers)

This is utter nonsense. If a compiler accepts this, I wouldn't call it
`forgiving', I would call it `braindead'. The left hand side of an 
assignment expression has to be a modifiable left hand value (or object,
as you wish). the putchar() function (or macro) isn't even a left hand
value. But you're right: putchar(c)= getchar() can be compared to
i= ++i. They're both utter nonsense. ;-)

kind regards,

Jos aka jos@and.nl
Newsgroups: comp.lang.c
From: stp@controls.ccd.harris.com (Stephen T. Pierce)
Subject: Re: Finding the number of days between two dates 
Originator: stp@rs2
Reply-To: steve@rtfm.mlb.fl.us
Organization: Space Coast Naturists
Date: Wed, 16 Dec 1992 14:26:57 GMT


Does anyone have any algorithms for finding the difference between two 
datetimes in hours, minutes or seconds?  Daylight Savings Time differences
seem to make this a bit of a bear.

Steve
-- 
INTERNET: stp@ccd.harris.com or steve@rtfm.mlb.fl.us
  DELPHI: STPIERCE				AOL: StephenTP
		Ask me about Space Coast Naturists!
Newsgroups: comp.lang.c
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Subject: Re: RFD: splitting comp.lang.c
Organization: University of Helsinki
Date: Thu, 17 Dec 1992 00:15:52 GMT

steveg@cadkey.com (Steve Gallichio) writes:
>How about comp.lang.c.howdoigetunbufferedinputwhenusinggetchar ?


Hey, don't forget comp.lang.c.main.returns.int.not.void,
comp.lang.c.pointer.declarations.dont.allocate.pointed-to.storage,
comp.lang.c.writing.tsrs, comp.lang.c.process.control,
comp.lang.c.other.unix.system.calls,
comp.lang.c.converting.from.or.to.other.languages,
comp.lang.c.software.engineering, and comp.lang.c.stupid.jokes. 
:-)

--
Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
   MS-DOS, you can't live with it, you can live without it.
Xref: sparky comp.lang.c:18568 sci.chem:5483 sci.math:17122