HDTenEightyP/NetNews huggingface dataset:
From: nicholas@odin.iti.gov.sg (Nicholas Tan (KSL))
Newsgroups: comp.lang.c
Subject: Re: Fast way of counting number of bits =1 in an int.
Keywords: bit operations
Date: 16 Oct 92 01:56:29 GMT
Organization: Information Technology Institute, National Computer Board, Singapore

In article <92Oct10.031840.26015@acs.ucalgary.ca>, puri@enel.ucalgary.ca (Ruchir Puri) writes:
> Hi there!
> 	I was wondering if software pundits out there know of 
> a better way of counting the number of bits=1 in an integer variable.
> The regular way is mask, shift, mask, shift,......
> 
> But it is slow and requires 32 shift and & operations. 
> Can anybody suugest a better solution.
> 
> I am interested in finding the difference between the number of
> bits that are 1 in two variables. 
> 
> I will appreciate any pointers to an effecient way...
> 
> Thanks a lot for your time...
> 
> --Ruchir
> 
> 
> -- 
> Ruchir Puri                    VLSI Gp., Dept. of Elect. & Computer Engg.
> puri@enel.UCalgary.CA          The University of Calgary, Calgary, CANADA - T2N1N4
> 403-220-4870 (Dept Ph.)        403-284-5825 (Home Ph.), 403-282-6855 (Dept FAX)

There's an interesting article in the December 1990 issue of Computer Language,
page 45, Quibbles &Bits.  It has 7 variations on counting the number of 1's in
a binary number.  You can pick and choose :)


- Nicholas
Newsgroups: comp.lang.c
From: hollasch@kpc.com (Steve Hollasch)
Subject: Re: yus21bs12yus2112yuix12bx ipwyx1xb
Summary: Followups to alt.sex ...
Organization: Kubota Pacific Computer, Inc.
Date: Tue, 13 Oct 1992 02:29:49 GMT

In article <1992Oct13.013054.18723@debbie.cc.nctu.edu.tw>
u8111091@cc.nctu.edu.tw () writes:
| I don't know how to use it.

    Good.  That means less competition for those of us who do.

______________________________________________________________________________
Steve Hollasch                                   Kubota Pacific Computer, Inc.
hollasch@kpc.com                                 Santa Clara, California
Newsgroups: comp.lang.c
From: newton@wilbur.psu.edu (Cynthia Newton)
Subject: spawn() question [SUMMERRY]
Organization: Penn State University, Center for Academic Computing
Date: Fri, 16 Oct 92 23:17:11 GMT

Thanks to:
: dkeisen@leland.stanford.edu 
: Dave Sisson <daves@vtucs.cc.vt.edu>
: "P.Bennett" <bennett@erich.triumf.ca> 
: brian_helterline <brianh@hpcvia.cv.hp.com>
: cybrspc!roy@cs.umn.edu (Roy M. Silvernail)

for responding via e-mail and those who responed on clc.
My question was about TC's spawn().
I did:
spawnvp(P_WAIT,"C:\TEST\TEST.EXE",NULL)

and it was not working. Solution is to use 2 back slashes instead of one 
or one forward slash. 
so the correct way is:
spawnvp(P_WAIT,"C:\\TEST\\TEST.EXE",NULL)
or
spawnvp(P_WAIT,"C:/TEST/TEST.EXE",NULL)

-- 
C Newton
Newsgroups: comp.lang.c,comp.lang.c++
From: kestes@nswc-wo.nswc.navy.mil (Kent Estes)
Subject: wanted: way to detect if stderr has been redirected...
Keywords: stderr, stream redirection
Organization: Naval Surface Warfare Center
Date: Tue, 13 Oct 1992 12:30:44 GMT

I am trying to make a function that will printf to stdout AND
to stderr IFF (if and only if) stderr has been redirected.
The only part I am not certain about is how to tell if 
stderr has been redirected.  The function fileno() is no
help -- it returns the file # of the first file associated
with the stream.

email replys appreciated,
                KL   (kestes@nswc-wo.navy.mil)
 


Newsgroups: comp.lang.c
From: dnl@convex.is.macsch.com (David Lombard)
Subject: Re: What is RPG ???
Organization: MacNeal-Schwendler Corp.
Date: Tue, 13 Oct 92 20:24:51 GMT


There's another alternate definition of RPG:

	REALLY PUTRID GARBAGE.

The ONLY language I've ever used that REQUIRED a coding form!

My *best* RPG story:

	One day I sat down at the *one and only* 129 keypunch (the rest
were 029's) to do a really quick program and merrily typed away.  After
going through the deck several times and correcting all the typo's, I
sauntered over to the card reader (the *really* slow one on an 1130) and
placed my deck in the hopper.  When my job finally came up (printed on
an 1132 of course), I was greeted by at least one error message per line.
To add insult to injury, the dumb compiler would print any of the code?!?!?

After *much* fussin' and cussin', I found The Culprit!  The keypunch decided 
not to actually punch the cards - it just wrote the text across the top!

How many languages/compilers do you know get OUTRAGED at blank lines?!?!?!

Don't forget the H!


Regards,
DNL
******************************************************************************
*               MY COMMENTS == MY OPINIONS != ANYBODY ELSES                  *
******************************************************************************
* David N. Lombard                               The MacNeal-Schwendler Corp *
* dnl@macsch.com                                 815 Colorado Blvd           *
* (213) 259-4911 FAX: (213) 259-3838             Los Angeles, CA  90041      *
******************************************************************************
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c
Subject: Re: |const| as an operator
Date: 14 Oct 92 23:55:56 GMT
Organization: negligable

Oh shoot!

forgot which newsgroup I was in!  the prior post is appropriate
to comp.lang.c++, and my newsreader has a bug that won't let
me issue a cancel.

Apologies all around.

Does anyone know if the behavior of "const" is the same in
ANSI C as it is in ANSI C++?

		-Richard Hartman
		hartman@ulogic.COM

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Never speak in absolutes.  It will always lead to trouble.
From: slahiri@jade.tufts.edu (Sandip Lahiri)
Newsgroups: comp.lang.c
Subject: Scanf and pointer problem : Thanx folks
Date: 14 Oct 92 14:02:44 GMT
Article-I.D.: jade.1992Oct14.140244.5333
Organization: Tufts University - Medford, MA
Originator: slahiri@jade.tufts.edu

I wish to thank all guys who took their times to help me out. Hey,
that was quick. Thanx buddies.

-Sandip
From: daffner@mentor.cc.purdue.edu (Lawrence Daffner)
Newsgroups: comp.lang.c
Subject: Re: help needed with curses problem
Summary: not curses' fault.
Keywords: curses help
Date: 12 Oct 92 07:11:02 GMT
Organization: Purdue University Computing Center


	You gotta put the source compile first, then the libs...

i.e.:    cc program.c -o program -lXa -lcurses -ltermcap

 or so... that's cos when the linker sees a lib, it zips through,
checks what libs it needs and links in only those. Before the source,
it needs no lib fns, so none get loaded...

Hope this helps....

-Larry
Newsgroups: comp.lang.c
From: andreas@andreashact.de (Andreas Kesenheimer)
Subject: Re: Strings and integer sizes
Organization: Halstenbach ACT GmbH
Date: Fri, 16 Oct 1992 08:33:07 GMT

In article <Bw1KEF.LqE@research.canon.oz.au>, greyham@research.canon.oz.au (Graham Stoney) writes:
|> andreas@andreas.hact.de (Andreas Kesenheimer) writes:
|> >Never trust in C-Compilers! To make shure you get what you want, not just only

(...)

|> This is a joke, right?. I'm not sure if you were being serious or not; it
|> certainly isn't good advice if you were. strcpy always copies the terminating
|> '\0' so there is certainly no need to memset it first, unless you want to waste
|> CPU time, or your productivity is measured in source-lines-of-code.
|> 
|> Graham

Unfortunately this was no joke, since I had such problems with programming a
MAC. By talking and writing to several people I found out, that memset is indeed
*not necessary* on most other machines - and especially with most other
compilers (today I'm programming at a different company different projects on
different machines, different OSses and different C-Compilers, so the former
problem is not reproduceable).

So, maybe my pseudo advice was misleading - sorry 'bout this.

	Andreas

-- 
Disclaimer 
Andreas Kesenheimer
Internet: andreas@hact.hact.de
Newsgroups: comp.lang.c
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Strings and integer sizes
Organization: Computer Science, University of Melbourne, Australia
Date: Sun, 11 Oct 1992 11:45:13 GMT

hartman@ulogic.UUCP (Richard M. Hartman) writes:

>In article <3568@carrousel.and.nl> jos@and.nl (Jos Horsmeier) writes:
[...]
>:Have a look at ANSI-C 3.5.7 Initialization:
>:
>:`An array of character type may be initialized by a character string
>:literal, optionally enclosed in braces. Successive characters of the
>:character string literal (including the terminating null character
>:if there is room or if the array is of unknown size) initialize the
>:elements of the array.'
>:
>:So, I agree that a sequence of bytes '1', '2', '3', without a terminating
>:zero-valued byte does _not_ conform to the conceptual string type, but 
>:I disagree that char zoe[3] = "123"; would be an erroneous initializer.
>
>It is erroneous. "123" is a character array constant of four characters,
>'1', '2', '3', '\0'.  Attempting to inialize an array of [3] with this
>is erroneous.   "123" would be a proper initializer for an array of size
>[4] or above.

Didn't you read Jos Horsmeier's post, Richard?
The one that you just replied to? Jos even quoted the standard
for you, so you don't have to rely on Jos' opinion.

"123" is NOT a character array constant of four characters, it is
a string literal of 3 characters, and the initialization is perfectly
legal.

>	char zoe[4] = "123";		// good
>	char zoe[3] = "123";		// possibly not flagged by compiler,
>					// but dangerous.

This is comp.lang.c, not comp.lang.c++, so the // comments are of course
illegal. Furthermore the second comment should read "legal, and
definitely accepted by the compiler, but possibly not what the programmer
intended".

Note: C++ differs from C on this issue.

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
Newsgroups: comp.lang.c
From: yho@janet.carleton.ca (Y. Ho(S.Kennedy))
Subject: How to execute "setenv ..." in c program???
Organization: Carleton University
Date: Wed, 7 Oct 1992 16:32:02 GMT

Since setenv is not a "sh" command, "system" function can't be used.
How can I do then?

Need Help!

Yushang
From: mcw@ukc.ac.uk (Mark Wheadon)
Newsgroups: comp.lang.c
Subject: Ups - the song!
Date: 7 Oct 92 15:57:25 GMT
Organization: Computing Lab, University of Kent at Canterbury, UK.


	[Apologies if you've seen this already in comp.windows.x.
	 I should have cross-posted, but didn't.]


Ups - you've used the debugger, now hear the song!

For a while now, a song I wrote/performed about, of all things, the ups
debugger has been available in a crude digitized form (SPARC audio
format) from many ftp sites around the world (e.g. contrib/ups-song.au
at export.lcs.mit.edu, lyrics in contrib/ups-song.ms).  To quote a
couple of responses I had shortly after making it available via ftp
(names changed to protect the innocent :-)

	From: someone@mprgate.mpr.ca
	Subject: UPS Song...

	Hi!

	I've just picked myself up from rolling on the floor, clutching
	my middle to hold back the pain from LAUGHING at the UPS song!


	From: someone@mlb.dmt.csiro.au
	Subject: ups-song.au

	BURT!!!!!     *** WOW ***
	That song is great! I can't believe it! We've just played it here
	(before 3 other grimacing scientists!!). Now that i've heard the
	song, where can i get the debugger??

The same song will shortly be available in glorious stereo on CD, as
part of the MUSENET '92 compilation - over two hours of music by USENET
readers on two Cd's for the grand price of $7 US + shipping.  The
deadline for first-run orders is 1 December and the CD's should be
shipped sometime that month.

To quote the ordering information (available via ftp as
anonymous@xcf.berkeley.edu:misc/netjam/doc/announcements/MUSENET/update):

        Actual Cost:
        $7 US for each 2-CD set.
        General Cost:
        $7 US base price for each 2-CD set, plus shipping:
                US:        $3.00 US for first set, $1.50 US for each additional
                Canada:    $3.50 US for first set, $1.75 US for each additional
                Europe:    $6 US for first set, $3 US for each additional
                Australia: $6 US for first set, $3 US for each additional

        Currency:
                Personal checks for US funds drawn on US banks - made
		         payable to ``Craig Latta''
                US Money Orders
                International Money Orders for US funds

The guy compiling, mastering and distributing this compilation is
Craig Latta <latta@xcf.berkeley.edu>

So... that's a double CD packed with music that includes the ups song,
all for $7 plus shipping - what are you waiting for!

Cheers,

bUrt

[Please note - I have no connection with this venture other then being
a contributor, and that no-one intends to make any money out of it.]
From: mlg@siemens.com. (Michael Greenberg)
Newsgroups: comp.lang.c
Subject: Re: Fast way of counting number of bits =1 in an int.
Keywords: bit operations
Date: 12 Oct 92 15:22:27 GMT

puri@enel.ucalgary.ca (Ruchir Puri) writes:

>Hi there!
>	I was wondering if software pundits out there know of 
>a better way of counting the number of bits=1 in an integer variable.
>The regular way is mask, shift, mask, shift,......

Here another approach...

Extract 8 bits at a time from your 32 bit word with shift and mask
operations.  Use the extracted byte as an index into a 256 element
table.  table[i] = number of bits set in 'i'. Sum the results.




--
Michael Greenberg                      email: mgreenberg@siemens.siemens.com
Siemens Corporate Research             phone: 609-734-3347
755 College Road East
Princeton, NJ 08540
From: omori@ee.fit.edu (Ricardo Omori)
Newsgroups: comp.lang.c
Subject: Looking for Sound libraries
Date: 15 Oct 92 23:47:06 GMT
Article-I.D.: yacht.omori.719192826
Organization: Florida Tech, CP/EE Dept.

Hello!

I'm looking for an include file that would
let me program/access a sound card like
Sound Blaster. I'd like to set the card to
record and play sounds from my own C program.

I'll appreciate any help.
Please send me info to
omori@ee.fit.edu
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c
Subject: Re: multidimensional arrays as parameters
Date: 15 Oct 92 20:45:45 GMT
Organization: negligable

In article <1992Oct14.215124.100265@Cookie.secapl.com> frank@Cookie.secapl.com (Frank Adams) writes:
>In article <1992Oct13.224918.21890@kakwa.ucs.ualberta.ca> bill@chaos.phys.ualberta.ca (Bill Burris) writes:
>>I was wondering how to pass a multidimensional array as a parameter.
>>
>>For a 1D array I do the following:
>>
>>void function( int * );
>>
>>int array[10];
>>
>>void function( int *data )
>>[...]
>>
>>Now for a 2D array if I do the following:
>>
>>int array2d[10][20];
>>
>>void fun2d( int * );
>
>I've seen two responses to this, both claiming the correct declaration is:
>
>void fun2d( int ** );
>
>This is incorrect.  array2d is not an array of pointers to arrays, but an
>array of arrays.  Thus, the automatic conversion yields a pointer to an
>array.  Thus fun2d should be:
>
>void fun2d( int * [20]);
>
>Isn't this in the FAQ?

Which begs the question, since the next array I pass may be [40][50],
is there a more general approach?  

I think that you might be stuck adding dimension params to the function
and doing the math yourself.  It might not be the ONLY way, and it is
certainly inconvenient, but it should work.  e.g.:

    void fun2d(int *arr, int xsiz, int ysiz)
    {
	...
        *(arr+(ysiz*ycoord)+xcoord) = value;    /* arr[xcoord][ycoord]=value; */
	...
    }

Note: the order in which your machine (row-major or column-major) stores
it's array-of-arrays will affect the math involved, it could also be:

        *(arr+(xsiz*xcoord)+ycoord) = value;    /* arr[xcoord][ycoord]=value; */

on some systems.  When I need to find out how a system stores it's
array-of-arrays I generally write a test program that defines and
initializes a 5by5 array of int then walk an int* through from the
start, printing the values as I go.  You'll either see all the values
in row 1, then row 2, etc or all the values in column 1, column 2,
etc.

Disclaimer: I have not compiled the above code and have not worked
with multidimensional arrays for some time.  You may have to fiddle
w/ the details (swap x & y?) to get it to work, but the concept
should be valid on most systems.

q: would |void fun2d(int a[][])| be of any use (I don't *think* so...)



		-Richard Hartman
		hartman@ulogic.COM

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"Smoke me a kipper, I'll be back for breakfast!"
From: puri@enel.ucalgary.ca (Ruchir Puri)
Newsgroups: comp.lang.c
Subject: Fast way of counting number of bits =1 in an int.
Keywords: bit operations
Date: 10 Oct 92 03:18:40 GMT
Organization: ECE Department, U. of Calgary, Calgary, Alberta, Canada

Hi there!
	I was wondering if software pundits out there know of 
a better way of counting the number of bits=1 in an integer variable.
The regular way is mask, shift, mask, shift,......

But it is slow and requires 32 shift and & operations. 
Can anybody suugest a better solution.

I am interested in finding the difference between the number of
bits that are 1 in two variables. 

I will appreciate any pointers to an effecient way...

Thanks a lot for your time...

--Ruchir


-- 
Ruchir Puri                    VLSI Gp., Dept. of Elect. & Computer Engg.
puri@enel.UCalgary.CA          The University of Calgary, Calgary, CANADA - T2N1N4
403-220-4870 (Dept Ph.)        403-284-5825 (Home Ph.), 403-282-6855 (Dept FAX)
From: kdq@quest.UUCP (Kevin D. Quitt)
Newsgroups: comp.lang.c,comp.software-eng,comp.sys.mac.programmer
Subject: Re: Productivity of a C programmer ?
Date: Fri, 09 Oct 92 16:53:42 PDT
Reply-To: srhqla!quest!kdq
Organization: Job quest  (805) 251-8210,  So Cal: (800) 400-8210

cga66@cbnewse.cb.att.com (patrick.v.kauffold) writes:
> You can find many "nominal" values, ranging from 1 SLOC/person/day
> to 5 SLOC/person/day, in the literature (Boehm comes to mind).

    That low?  Milspec used to be 15 SLOC/p/d for compiler/kernel level
complexity.


 _
Kevin D. Quitt                                 Job Quest (805) 251-8210
srhqla!quest!kdq                               Learn How to Get a Job in SoCal

                96.37% of all statistics are made up.
From: per@front.se
Newsgroups: comp.lang.c
Subject: unsigned long version of time_t?
Date: 7 Oct 92 14:11:48 MET
Distribution: world
Organization: Front Capital Systems AB, Sweden

What is the canonical way to extend the range of time_t? If my
calculations are correct, end-of-time for a signed long is in 2038,
but an unsigned long can reach 2106.

Would it be possible to extend the range of the time_t format by using
an unsigned long? H&S mentions this, but is vauge on details.

Are there any reasons (except historical) why time_t should be signed?

I have the experience that if you pass a negative value to some
standard library functions described in time.h, they will explode and
go down in flames. (VAX C). Perhaps future versions will handle this?


Per Lindberg (per@front.se)         !      __!__
Front Capital Systems, Box 5727,    !  _____(_)_____  Ceci n'est pas une Piper
11487 Stockholm, Sweden. 8-6611510  !     !  !  !
Newsgroups: comp.lang.c
From: wittesa@reks.uia.ac.be (Willy Wittesaele)
Subject: Re: Question about fread() and fwrite()!
Organization: U.I.A.
X-Newsreader: Tin 1.1 PL5
Date: Fri, 16 Oct 1992 14:36:43 GMT

Hello ,

After your write you should do a seek with the fseek() function to the
record you want to read , in your example  to the beginning of the file.

see the manual for an explanation of fseek()

Good luck , Willy
Xref: sparky comp.lang.c:14748 comp.software-eng:3673 comp.sys.mac.programmer:16724
From: mhughes@comtch.spk.wa.us (Mark Hughes)
Newsgroups: comp.lang.c,comp.software-eng,comp.sys.mac.programmer
Subject: Re: Productivity of a C programmer ?
Date: 9 Oct 92 18:09:01 GMT
Organization: Waffle BBS at CompuTech Spokane, Washington

cjh1@ellis.uchicago.edu (chi ju huang) writes:
> Could any one show me the light on
> "Average productivity of a C programmer in today's industry in terms of
> number of lines of source code produced per day."
> 
> What I need is the number (lines/day), the conditions and the assumptions
> under which the number is derived, and the reliable source of this model.
 
  "There ain't no sech animal."  The number of lines per day a programmer 
turns out can vary incredibly.  Much of the programmer's work is thinking 
- and that reduces the number of lines, usually.  Other times, the 
programmer will spew out a hundred or a thousand lines in a day.  One 
good rule of thumb is that the time to program a project increases 
geometrically with the size of the program, not linearly.  A small 
program can be written in 15 minutes...  but a program 20 times larger 
may take a month...  Etc.
 
  The best thing to do is to ask a programmer to evaluate how long it 
will take a team to write your project, and then add 20% or so...
 
Newsgroups: comp.lang.c
From: sem@isi.itfs.nsk.su (Tarasov Eugene)
Subject: Help: C++ and C grammar required
Date: Tue, 13 Oct 1992 03:15:22 GMT
Reply-To: sem@isi.itfs.nsk.su
Organization: Institute of Informatics Systems, Novosibirsk

Help!
   I need BNF description of C++, ANSI C, and KR C as well. Where can I
get it from, or at least yacc definitions?
   GNU C++ yacc definitions  unacceptable  beacuse  they  contact  with
BISON too much and too closely.
   Is there pure context-free C++ grammar at all?

Thanks,
  Eugene Tarasov
  sem@isi.itfs.nsk.su
From: yang@bmsr10.usc.edu (Fang Yang)
Newsgroups: comp.lang.c
Subject: How does one input text/number in Turbo C graphic mode?
Date: 13 Oct 1992 10:25:28 -0700
Organization: University of Southern California, Los Angeles, CA
NNTP-Posting-Host: bmsr10.usc.edu

I have seen many softwares that can do text/number I/O in graphic mode
(e.g. SigmaPlot). But in Turbo C, one can only find how to output
text in graphic mode. Someone, who knows how to input in Turbo C graphic
mode, please reply to my E-mail address for I don't regularly read this
news group.

I also have a question regarding using Ctrl-Break in Turbo C.
Turbo C allows setting a user-made Ctrl-Break handler. My experience is
that it doesn't have higher priority than other interrupts. In other
words, pressing Ctrl-Break won't stop an interrupt-related task. Any
comments, suggestions and experience are welcome.
 
Xref: sparky comp.lang.c:14887 comp.programming:2885