HDTenEightyP/NetNews huggingface dataset:
From: ark@alice.att.com (Andrew Koenig)
Newsgroups: comp.lang.c
Subject: Re: Is this ANSI?
Date: 19 Nov 92 13:33:50 GMT
Article-I.D.: alice.24238
Reply-To: ark@alice.UUCP ()
Organization: AT&T Bell Laboratories, Murray Hill NJ

In article <9eRguB1w165w@quest.UUCP> srhqla!quest!kdq writes:

>     Here is (a simplified version of) the struct that the compiler
> calls an error:

> struct FM
> {
> 	short	data_len;
> 	char	data[];        /*  This line is the kicker  */
> };

>     As I recall, ANSI says this is legal, with sizeof( struct FM) is 2 
> bytes, and offsetof( struct FM, data) is 2.

I don't think you recall correctly.  If nothing else, there is no
requirement that sizeof(short) <= 2.  Moreover, since every object,
including members of structures, must have nonzero size, the line
in question would have to allocate at least one element.  I would
therefore expect that if I hunted through my copy of the Standard,
I would find that this fragment is indeed illegal.

I'm not going to bother to hunt, though, because I think your question
conceals a more important question that I can answer much more easily.
The point is to ask why you're trying to do this in the first place.

That is, why bother with what looks like an array with no elements?
What use is it?  The only answer I can think of is that you're intending
to allocate `extra' memory and then subscript off the end of the array --
and the standard definitely does not allow that technique, period.
-- 
				--Andrew Koenig
				  ark@europa.att.com
From: n8743196@henson.cc.wwu.edu (Jeff Wandling)
Newsgroups: comp.lang.c
Subject: Re: Multiple Parameter Passing (unspecified number)
Date: 17 Nov 92 10:58:37 GMT
Article-I.D.: henson.1992Nov17.105837.21867
Organization: Howling Dog

misar@rbg.informatik.th-darmstadt.de (walter misar) writes:

>In article <92321.124834GNR100@psuvm.psu.edu>, <GNR100@psuvm.psu.edu> writes:
>>    Hi.
>> 
>>    I'm looking to write a function that accepts any number of paramerter.
>> There will be at least two, an int and a char[]. The rest will all be char[]'s.
>> I need to know how this is done.  The meathod would be similar to that of
>> printf(), so if anybody know how that works, please let me know.

>If you use an ANSI compiler it will look like this:

>#include <stdarg.h>

>void fun(int i,char s[],...)	/* 3 dots exactly	*/
>{  va_list argp;
>    /* more variables */

>   va_start(argp,s);		/* 2nd arg is last named fun-arg	*/
>    /* with va_arg(argp, TYPENAME) you can step through the arg-list,
>       the macro will provide always the next one, TYPENAME is the type
>       of the arg (in this case char * or char [])
>    */
>    /* some code */
>    va_end(argp);

>}

System: Sun 3/50, SunOS 4.1.1b

I'm trying to do a similar thing, except my function doesn't know what type
to expect.  The next "variable argument" could be any simple type.  How
do I deal with this?  Is there a way to switch on the type of the next
argument? When using union's for example---


  hash_insert(table,name,...) 
  ....
  {
    
    ....
    va_list argp;

    type = va_"type?"(argp,???);
    
    ....
   }

-- 
perl -e '$a="Japhuneasorcttlk h eae r r ,";$]=0;$s=$];while($s<4){do{$_ .= pack
("c",vec($a,$],8));$]+=4;}while($]<length($a)&&vec($a,$],8)!=32);$s++;$]=$s;$_
.= ' ';}chop;print;' Jeff Wandling  <jdw@physics.wwu.edu>  "will hack for food"
Newsgroups: comp.lang.c
From: pcli@napier.uwaterloo.ca (Connie Li)
Subject: go32 of djgpp 1.09
Keywords: gcc djgpp
Organization: University of Waterloo
Date: Tue, 17 Nov 1992 20:48:49 GMT


My go32 hang my PC when I supply the wrong name to it.
ie. go32 a.ou instead of go32 a.out

Anyone has the same problem ?  Or fix ?

Thanks
From: sasghm@theseus.unx.sas.com (Gary Merrill)
Newsgroups: comp.lang.c
Subject: Re: Is this ANSI?
Date: 23 Nov 92 16:54:28 GMT
Organization: SAS Institute Inc.
Originator: sasghm@theseus.unx.sas.com


In article <24262@alice.att.com>, ark@alice.att.com (Andrew Koenig) writes:
|> In article <By0vu2.7AF@unx.sas.com> sasghm@theseus.unx.sas.com (Gary Merrill) writes:
|> 
|> > I think "does not allow that technique" is a little strong.  What you
|> > *can* do is
|> 
|> 	struct FM
|> 	{
|> 	   short data_len;
|> 	   char  data[1];
|>         };
|> 
|> 	struct FM *fmptr;
|> 
|> 	fmptr = malloc( sizeof(struct FM) + ??? );
|> 
|> > where the ??? is the number of bytes of your data minus 1.  Some may
|> > regard this as "impure", but it is not forbidden by the standard and
|> > is eminently portable.
|> 
|> Oh, really?  Can you give me concrete evidence that the C standard allows it?
|> 
|> More specifically, after executing the code above, can you give me
|> evidence that referrint to fmptr->data[i] is allowed when i>1?
|> -- 
|> 				--Andrew Koenig
|> 				  ark@europa.att.com

Seems to follow quite directly from 3.3.2.1.  I don't see any
problem here at all.

One may want to argue that any reference beyond the end of the
array is not ensured of being a valid pointer (3.3.6), and I
concede the obvious fact that if a struct FM were *defined*,
then such a reference is "undefined".  However, in the example
given, the space is allocated via a malloc() call and hence
must conform to the requirements for such allocations (4.10.3).

I guess the question then reduces to:  Could an ANSI-conforming
compiler allocate memory in such a way that the given example
would not work?  I may have to admit that a compiler *could*
do this -- but it would appear to take a special effort of
perversity to accomplish it.  The memory allocated will be contiguous.
Then &fmptr->data[0] will point into this contiguous memory.
Now, how to arrange it so that &fmptr->data[2] does *not* point
into this contiguous memory ...  I suppose it can be done.

This seems especially perverse since one could easily address
the desired memory by a pointer initialized to &data[0].  Thus,
for example,

	char *p;

	p = &fmptr->data[0];

and

	p[1024]

(or whatever) is perfectly okay.  But data[1024] isn't.  It
isn't as though the memory isn't there, or that we can't
reference it.  Makes you wonder.


-- 
Gary H. Merrill  [Principal Systems Developer, C Compiler Development]
SAS Institute Inc. / SAS Campus Dr. / Cary, NC  27513 / (919) 677-8000
sasghm@theseus.unx.sas.com ... !mcnc!sas!sasghm
Newsgroups: comp.lang.c
From: west@xi.uleth.ca (Greg West)
Subject: abort, retry, fail ...
Organization: University of Lethbridge
Date: 23 Nov 92 15:25:17 GMT

    I am using Borland C++ (Using the C part of the compiler).  I am doing some
data logging with the machine as well as controlling.  I am writing to floppy
disk but if there is a failure in writing to floppy the entire program halts. 
Most C functions just return a failure on failure rather than stopping the
program.  How do I write an interrupt handler to accomplish this.  If anyone
knows some good books on this subject ... or has some code fragments of how to
do this then please forward this information to me at:
                 west@alpha.uleth.ca
Thankyou in advance for the information.

                        Greg West
Newsgroups: comp.lang.c
From: ebergman@nyx.cs.du.edu (Eric Bergman-Terrell)
Subject: Re: BCD arithmetic
X-Disclaimer: Nyx is a public access Unix system run by the University
	of Denver for the Denver community.  The University has neither
	control over nor responsibility for the opinions of users.
Organization: Nyx, Public Access Unix at U. of Denver Math/CS dept.
Date: Tue, 17 Nov 92 15:12:58 GMT

In article <1992Nov17.124233.20938@cs.joensuu.fi> jmeri@cs.joensuu.fi (Juha Meriluoto) writes:
>I am working on a project that needs BCD arithmetics.
>Could anyone give me pointer(s) to BCD arithmetics packages
>written in C (preferably public domain, I don't have money to
>spend on this one...)  Thanks in advance!

There's a BCD class included with the Borland C++ compilers.  Also, there is
BCD arithmetic built directly into the 8x87 family of math coprocessors.
If you're willing to write maybe 20 lines of in-line assembly code you can
use the hardware BCD instructions.  I don't know whether the 8x87 emulation
library shipped with the Borland compiler emulates these instructions, or 
whether the emu87.dll in windows does either - but if you have the math chip
or an 80486 DX, you've everything you need.

Terrell

>
>	JMe
>
>-- 
>******************************************************************************
>Juha Meriluoto    e-mail:   jmeri@cs.joensuu.fi
>                  letters:  Nuottaniementie 16 A 9  80140 JOENSUU  FINLAND
>                  phone:    +358-49-379040 


Newsgroups: comp.lang.c
From: niu@prancer.eche.ualberta.ca (Shaohua Niu)
Subject: Non-block read
Organization: University Of Alberta, Edmonton Canada
X-Newsreader: Tin 1.1 PL3
Date: Sat, 21 Nov 1992 05:00:38 GMT


To read from a socket without blocking, you can either use fork() to
create a new socket, or use select() to check whether you get something
to read in the socket. Select() is especially convenient when there
are more than one clients trying to read the socket. Try 'man select'
for more details.

--

---------------------------------------------------------------------  
  (_--_)  Shaohua Niu           |  `Have a nice day, and a nice night.'
  ( oo )  Dept. of Chem. Eng.   |  Email: niu@prancer.eche.ualberta.ca  
   )  (   Univ. of Alberta      |  Phone: (403) 432-7803 (Home)         
   (__)   Canada, T6G 2G6       |         (403) 492-2971 (Office)
----------------------------------------------------------------------
From: jhoriga@cad052.NoSubdomain.NoDomain (John Horigan~)
Newsgroups: comp.lang.c
Subject: Re: external sorting
Date: 17 Nov 92 16:46:31 GMT
Organization: Intel Corp.

In article <1992Nov17.103111.19839@di.unipi.it>, ntranqu@caticsuf.cati.csufresno.edu (Nico Tranquilli) writes:
|> I'm writing an article on how to sort large files using Mergesort 
|> and I was wondering if anyone out there know of other good
|> sorting algorithms that can be used for external sorting too. 
|> 
|> --
|> Nico Tranquilli
|> v. Ruffini, 13
|> 62012 Civitanova Marche (MC) - Italy
|> phone: +39 (50) 550-266
|> home phone: +39 (733) 770-332
|> net: ntranqu@caticsuf.cati.csufresno.edu

Check out Radix Sort. It's easy to implement as an external sort
and it sorts in O(n) time. Cormen, Leiserson and Rivest's _Introduction
to Algorithms_ has a good description as do many algorithm books. Do
you describe both standard merge sort and natural merge sort in your 
article? (Natural merge sort takes advantage of pre-existing order
in your data.)

------------------------------------------------------------------------
John W. Horigan     GRP Engineer   DT  Physical Design CAD  Validation
Intel, Santa Clara  (415)765-4773  M/S: RN4-38  jhoriga@scdt.intel.com
Newsgroups: comp.lang.c
From: blume@tyrolia.Princeton.EDU (Matthias Blume)
Subject: Re: The Correct Way To Write C if-Statements
Reply-To: blume@tyrolia.Princeton.EDU (Matthias Blume)
Organization: Dept. of Computer Science, Princeton University
Date: Mon, 16 Nov 1992 17:14:36 GMT

In article <1992Nov16.094833@gese.ge14.mdadv.gv.at>,
sca@gese.ge14.mdadv.gv.at (Petzi Schweda) writes:

[lots of stuff deleted]

|> Generally I would tend to use the "if"-way if what's happening upon the 
|> condition has a major influence on the behavior or structure of the program,
|> and the "=(==)"-style when "flag" isn't so important at all ...
				     ^^^^^^^^^^^^^^^^^^^^^^^^^
In this case, you don't need the assignment at all...

|> 
|> By the way, I think that the whole discussion isn't one of "personal taste" 
|> or something like that - much more it's about how someone can get a 
|> feeling what some code written by somebody else does.
|> If your'e working in an ivory tower whatever makes you work happy is
perfectly
|> right - but when working as a group (wer'e here 6) you have to establish
|> conventions to avoid misunderstandings and save time and money ...

The first convention would be that all members of the group learn to program
in C (all parts, not only the intersection of C and Pascal).
Then nobody would be confused by something common like 
	flag = (x == y);

[other stuff deletes]

-Matthias
Newsgroups: comp.lang.c,comp.software-eng
From: travis@eecs.nwu.edu (Travis Marlatte)
Subject: Re: Will we keep ignoring this productivity issue?
Organization: Rauland-Borg Corporation, Skokie IL
Date: Fri, 20 Nov 1992 23:15:36 GMT

Geoff Miller says that it is possible to teach a skill to a certain level.
Going beyond "good" requires an innate ability that can't be taught.
[my paraphrase]

Ralph Johnson replies with:

> I don't think I misunderstood.  I disagree. 

> Sure, some people that you teach become much better than others.
> But *everybody* who has skills learned them.  *Somebody* taught
> Miles Davis to improvise, even if that somebody was himself (which 
> it probably was, in part, but he could probably tell you the many
> people who helped).  The claim that the main reason why some people
> do better than others is because some people are geniuses and other 
> people are not is sheer mysticism.  I bet Miles Davis is not a
> genius on any standardized test.  "

I don't think that Geoff was saying that these people were
intellectual geniuses but that the skills they had went beyond
a teachable level. And somehow, I think that you agre.

Falling back to "... even if that somebody was himself" is kindof
weak. Yes, his talents came from an inner strength BLAH, BLAH, BLAH.

People do have innate abilities in differing areas. That's what keeps
life interesting.

-- 
Travis Marlatte
travis@eecs.nwu.edu
708-297-0055
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Newsgroups: comp.lang.c
Subject: Re: Is this ANSI?
Date: 23 Nov 92 22:29:49 GMT
Organization: University of Helsinki

jlnance@eos.ncsu.edu (JAMES LEWIS NANCE) writes:
>I asked my C mentor about this once, and he pointed out that the
>compiler is free to store the members of the structure in any order.

Not in C.  Structure members have to appear in the same order as they
are declared.  This was so way back in 1978, in K&R-1 (p. 196).  Any
compiler that gets this wrong is seriously broken.

--
Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
   MS-DOS, you can't live with it, you can live without it.
From: lpeters@postmaster@hq.af.mil (Leslie D Peters)
Newsgroups: comp.lang.c
Subject: Re: *** IMPORTANT DISCOVERY ***
Date: 20 Nov 92 15:04:30 GMT
Reply-To: lpeters@marge.hq.af.mil
Organization: 7th Communications Group

In article <1992Nov16.221156.18458@spock.UUCP>, kurgan@spock.uucp (Andrew Twyman) writes:
|> In article <1992Nov13.210911.3086@msuinfo.cl.msu.edu> knaggs@cps.msu.edu (Scott A Knaggs) writes:
[ severe noise removed ]
|> Not only is this too sick to be on rec.humor (which isn't necessarily bad),
|> but it's nauseating and DUMB!  Keep it out of my face.  You're even more of a
|> pervert than I am, and that's a sick thought.
|> -- 
Since you want it out of YOUR face, you deemed it necessary to put it back
in MY face.....consider this a incendiary grenade on your pitiful wood-
powered flame.
-- 
/============================================================================\
|                    ___                     |                               |
|       ___....-----'---`-----....___        | I haven't lost my mind --     |
| =========================================  |                               |
|        ___`---..._______...---'___         |  it's backed up on            |
|       (___)      _|_|_|_      (___)        |   tape somewhere.             |
|         \\____.-'_.---._`-.____//          |                               |
|           ~~~~`.__`---'__.'~~~~            | lpeters@marge.hq.af.mil       |
|                   `~~~'                    |                               |
\============================================================================/
Newsgroups: comp.lang.c
From: 11jmitchiner@gallua.gallaudet.edu
Subject: FTP sites that spec. in C 
Organization: Gallaudet University
Date: Fri, 20 Nov 1992 20:49:31 GMT

	Are there any FTP sites available that have C routines and source
codes?  (Especially in the communications field)  I'm looking for a FTP site
so I can pick up some source codes as I'd like to see how BBS programs and
so forth can run in C.

Thanks.

Jon Mitchiner
11jmitchiner@gallua.bitnet
11jmitchiner@gallua.gallaudet.edu
11jmitch@gallux.gallaudet.edu


Newsgroups: comp.lang.c
From: cs202144@umbc8.umbc.edu (cs202144)
Subject: Re: How to print an integer as binary?
Organization: University of Maryland, Baltimore County Campus
Date: Thu, 19 Nov 1992 17:19:03 GMT

> Assuming that:
> int i = 203;
> How do I display 'i' as 11001011?

Someone posted something similar to this and it worked so I cleaned it up and
made it so you can easily install it into pre-existing code...Here goes:

void dtob (unsigned int i)
{
  if (i > 1)
     dtob (i >> 1);
  putchar(i & 1 ? '1' : '0');
}

Nice and short and portable ;)

I may even use it myself since it seems to be working so well so far...
Newsgroups: comp.lang.c
From: eager@eagercon.com (Michael J. Eager)
Subject: Re: Reconfigureable C-compiler for small microprocessors
Reply-To: eager@eagercon.com
Organization: Eager Consulting
Date: Thu, 19 Nov 1992 17:22:12 GMT

In article 090@comp.compilers, jack@tequila.vlsi.auc.dk (Jack Bukholdt Andersen) writes:
>We are looking for a C-compiler, which allows the target instruction-set
>to be reconfigured. Something like GNU gcc - but for much smaller
>processors.

Retargetable and reconfigurable compilers are what I would consider an
advanced research project.  I have seen some for microprogramming, but the
description required is extensive.  gcc is not retargetable; it is designed
so that the code generator can be re-written easily, but so was pcc.

---
Michael J. Eager		Michael.Eager@eagercon.com
Eager Consulting		(415) 325-8077 
1960 Park Boulevard, Palo Alto, CA 94306-1141

Lines: 14
Date: Thu, 19 Nov 92 11:19:31 MST
Newsgroups: comp.lang.c
From: curtisn@SAS (Curtis Nelson)
Subject: Help with ASM/C interface
Organization: BYU

Hey fellow nerds!
I have a question I hope one of you can help me with.  I'm using Borland C++ 
3.0 and I am trying to write a simple assembly language routine in my code.  
My question is, how do I pass vaues back and forth?  For example, if I push 
a value onto the stack in assembly, how con I retrieve that value from C?  I 
know I can use the stack, but how do I access an item on the stack?  I've 
looked at 'pop', but that appears to only work in C++, and I'm writing this 
in straight C. 

I would appreciate any help!
Thanks!

Curtis Nelson
curtisn@sasb.byu.edu
Xref: sparky comp.lang.c:16901 comp.software-eng:4436
From: richard@crowded-house.den.mmc.com (Richard Armstrong)
Newsgroups: comp.lang.c,comp.software-eng
Subject: Re: Will we keep ignoring this productivity issue?
Date: 20 Nov 92 19:21:49 GMT
Organization: Martin Marietta

Can we start ignoring it again?

Perhaps send it to the software engineering group?


-- 
My company never said any of this... I didn't either.
Richard Armstrong, Software Engineer, Martin Marietta
Email->>>> richard@crowded-house.den.mmc.com <<<<-Email 
Newsgroups: comp.lang.c
From: rene@hamel.uucp (Rene Mueller)
Subject: Re: pointers to functions
Keywords: pointers functions parameters
Organization: Free University of Berlin, Germany
Distribution: na
Date: Thu, 19 Nov 1992 17:36:48 GMT

In article <1992Nov6.234729.13866@koko.csustan.edu>, pendell@deneb.csustan.edu (Brian Pendell) writes:
|> Greetings!
|> 
|> As many of you already know, the declaration
|> 
|> double (*pfun) ();
|> 
|> declares pfun to be a pointer to a function which returns double.
|> 
|> Now, how do I call the function using the pointer? That is, the next
|> 
|> instruction should be:
|> 
|> "Call the function pointed to by pfun with parameters A and B"
|> 
|> function (A,B), in other words.
|> 
|> Any suggestion?
|> 
|> 
|> 	-- Brian Pendell (pendell@ceti.csustan.edu)

the same way you reference EVERY pointer:
(*pfun)(paramlist);
you must write (*pfun)() cause funktion calling has a higher priority than
dereferencing pointers...

	Rene
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Newsgroups: comp.lang.c
Subject: Re: the abs() function in C
Date: 22 Nov 92 14:02:28 GMT
Organization: University of Helsinki

alpha@waggen.twuug.com (Joe Wright) writes:
>This is almost always a macro like:
>
>#define abs(x) ((x)>=0 ? (x) : -(x))

It may be true that most systems define abs as a macro (I don't have
enough experience with different systems to know), but the above way
is not a good way for a standard conforming system, since it evaluates
its arguments multiple times.

>Look around.  Maybe you can simply declare it ..
>
>	extern int abs();

Or preferably by including <stdlib.h> (although it doesn't work on
non-standard systems, of course).

--
Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
   MS-DOS, you can't live with it, you can live without it.
Newsgroups: comp.lang.c
From: mitch@nosc.mil (Ray Mitchell)
Subject: Pulling Your Leg
Organization: Naval Ocean Systems Center, San Diego, CA
Date: Fri, 20 Nov 1992 00:14:19 GMT


I think that the would be "submarine officer" is pulling everyone's leg.
I know that the guy who wants someone to do his job for him is.  His is
merely a sarcastic response to the "submarine officer".

By the way, I don't know what I'm doing at my job either.  Is someone
willing to do it for me?

Ray
Newsgroups: comp.lang.c,comp.software-eng
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c
Subject: Re: strange things with gcc
Date: 17 Nov 92 09:15:36 GMT
Article-I.D.: goanna.15989
Organization: Comp Sci, RMIT, Melbourne, Australia

In article <9232210.1910@mulga.cs.mu.OZ.AU>, carl@montebello.ecom.unimelb.EDU.AU (Carl Brewer) writes:
>  wonder if anyone can offer a suggestion as to how to get this little
> routine to work.

Well, why don't you start by telling us what it is supposed to do?

I see you are posting from Melbourne University.  I know a lot of the
people in the Computer Science department there, and they really are quite
competent to help you with C/UNIX problems.

> maybe there is some other way to clear the buffer from stdin (preferable
> without using ioctl) ????

There are TWO repeat TWO buffers involved.
There is a stdio buffer which holds characters that your program has
read from the operating system.  Typically when reading from a terminal
this is the rest of the current line.  (And the UNIX mapping for '\n' is
LINE FEED not CARRIAGE RETURN.)  This is the buffer which fflush(stdin)
flushes in the System V library (which is probably what acc uses).

If all you want to do is discard the rest of the current line, the simple
answer is to read whole lines in the first place, using fgets().  (I do
hope you understand some of the reasons why scanf() is _not_ a good thing
to use for reading from a terminal.)

But there is ANOTHER buffer.  UNIX lets you type ahead.  There may be several
lines that you have typed, which the operating system is hanging onto until
your program asks for them.  That buffer is part of the "terminal driver",
and if you want to flush that one too you will _have_ to use ioctl.  It is
not at all hard to use.  (It is conceivable that fflush(stdin) _might_ issue
that ioctl() itself, but the "fflush" manual page for SunOS 4.1.2 certainly
doesn't read that way.)

I have written many many interactive programs under UNIX, and have never
needed fflush(stdin).  It really would help a lot if you told us what you
are trying to accomplish.
From: Bharathi@Cedar.Buffalo.Edu
Newsgroups: comp.lang.c
Subject: Coding Standards Manual for C needed
Date: 20 Nov 92 22:58:57 GMT
Reply-To: Bharathi@Cedar.Buffalo.Edu
Organization: CEDAR Research Group / Dept. of Comp.Sc. SUNY - Buffalo
Originator: bharathi@aardra.cs.buffalo.edu


There was a manual on C coding standards somewhere on the net.  
Can anyone help me find that please

Thanks in advance

Chandra
Newsgroups: comp.lang.c,comp.lang.c++,alt.tasteless.jokes,rec.humor