HDTenEightyP/NetNews huggingface dataset:
From: jaorans@pbhyg.PacBell.COM (Jeff Oransky)
Subject: Re: General data structure and algorithm C source
Reply-To: jaorans@PacBell.COM (Jeff Oransky)
Organization: Pacific * Bell, San Ramon, CA
Date: Wed, 9 Sep 1992 13:54:07 GMT

In article <1992Sep9.054305.26077@nuscc.nus.sg> ccewch@nuscc.nus.sg (Wong Chee Heng) writes:
>May I know if there is any sample C source that implement data structure
>like linked lists, B-tree, sorting, etc. that are published in quite a 
>number of books on C. 
>
>Thanks for any info.
>
You might try "Advanced Turbo C programming" by Herbert Schildt.  I found
and excellent introduction to linked lists and sorting there.

------------------------------------------------------------------------------
! Jeff Oransky             !   "Hope is the thing with feathers ......"      !
! Pacific Bell             !         Woody Allen                             !
------------------------------------------------------------------------------
Newsgroups: comp.lang.c
From: hsingh@seas.gwu.edu (harmel singh)
Subject: comp.lang.c -> FAQ
Organization: George Washington University
Distribution: usa
Date: Mon, 7 Sep 1992 21:22:04 GMT

i am looking for a copy of comp.lang.c FAQ.
can anybody tell me of the ftp site from where i can retrieve it.

thanx

hks
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Newsgroups: comp.lang.c
Subject: Re: Dropping a n from a fprintf()
Date: 15 Sep 92 20:25:41 GMT
Organization: University of Helsinki

nadeau@JSP.UMontreal.CA (Nadeau Jean-Claude) writes:
>		item[ strlen(item) - 1 ] = '\0';

I pointed out the fallacies of the above code in a previous message in
this thread already, but I want to do it again, because I was bit by
code like the above often enough while I was a beginner in C.

a) You should check that the last character really is a newline before
   you zap it.  (This was quite correctly pointed out in the material I
   deleted, but repetition never hurts.)

b) The length of the string can legitimately be 0 (if the line begins
   with a '\0' character).  This is _quite_ rare, but that doesn't stop
   it from happening (yes, I've seen it, although it was during a
   prototyping stage, and I just happened to redirect the wrong file as
   input).  What happens if strlen returns 0?  That depends on several
   things (signedness of the strlen return value, among others), but 
   you can rest assured that there will be no good results.  Even if the
   code works, it only works by coincidence, which is worse that code
   that doesn't work at all.

--
Lars.Wirzenius@helsinki.fi
Newsgroups: comp.lang.c
From: s1110238@giaeb.cc.monash.edu.au (Lee Hollingworth)
Subject: Re: Command Line Arguments
Organization: Monash University, Melb., Australia.
Date: Fri, 11 Sep 1992 08:59:08 GMT

gordon@osiris.cso.uiuc.edu (John Gordon) writes:

>bx314@cleveland.Freenet.Edu (Joseph J. Gebis) writes:


>>would write an example of a program that passes command line arguments
>>to a separate function that then prints them on screen.

>	Was there a specific language you had in mind for this?

	Isn't this comp.lang.c ?

Lee.
Newsgroups: comp.lang.c
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Dropping a n from a fprintf()
Organization: Computer Science, University of Melbourne, Australia
Date: Fri, 11 Sep 1992 12:54:38 GMT

cee1@ra.msstate.edu (Charles Evans) writes:

>	while ((fgets(fp1,20,item)) != 0)

This should be fgets(time,20,fp1).
For some unknown reason the FILE* argument to fgets is the last argument,
instead of the first.

-- 
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!
From: ugo@oliver.sublink.org (Ugo Cei)
Newsgroups: comp.lang.c
Subject: Re: Dropping a n from a fprintf()
Date: 13 Sep 92 11:06:34 GMT
Organization: Oliver System - Pavia ITALY

cee1@ra.msstate.edu (Charles Evans) writes:

>	char *item;         /* also tried stuff like char item[20];,
>				same results */

You should seriously ponder why "char item[20]" is correct and "char
*item" is not. Go back to the chapter on pointers and arrays.

>	while ((fgets(fp1,20,item)) != 0)

I wonder how could this code work in the first place. The "fp1" and
"item" arguments to "fgets" should be exchanged. Are you typing from
memory ?

>I shoots the \n in the fprintf() .. I want it on one line

Getting to the point, I have once seen this idiom used to remove the
occasional '\n' at the end of line obtained via fgets:

	strtok(item, "\n");

I did never stop and think about it long enough to verify that it
should indeed work as expected in all cases. This snippet of code came
from a reputed source, although I can't remember who it was, so I am
just using it blindly. Any comments ? 

					Ugo

-- 
Ugo Cei --- Via Colombo 7 - 27100 Pavia - ITALY   |
         -- Sublink:  ugo@oliver.sublink.org      | "Real programs dump core"
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Newsgroups: comp.lang.c
Subject: Re: Sets in C
Date: 11 Sep 92 13:22:12 GMT
Organization: University of Helsinki

kjb@cgl.citri.edu.au (Kendall Bennett) writes:
>Why not? Who says that a bitfield has to be 32 bits - make it as big as
>you want.

You can't (portably) make a bitfield as big as you want, only as big as
an unsigned int.  A better idea is to use an array of unsigned ints,
then calculate the index into the array and which bit in that array
element.  Something roughly like:

	#include <limits.h>
	#define INT_BITS (sizeof(int) * CHAR_BITS)
	unsigned set[MAX_SET_MEMBERS / INT_BITS + 1];
	#define INDEX(n) ((n) / INT_BITS)
	#define ELEMBIT(n) ((n) % INT_BITS)

Add element to set:
	set[INDEX(elementnumber)] |= ELEMBIT(elementnumber)

And similarly for other operations.

--
Lars.Wirzenius@helsinki.fi
Newsgroups: comp.lang.c
From: wb@tornado.kodak.com (wb@tornado.kodak.com)
Subject: WANTED: XDR Libraries for MSDOS
Keywords: XDR, MSDOS, RPCGEN
Organization: Digital Equipment Corp. (Telstar), Rochester, N.Y. 14653
Date: Wed, 9 Sep 1992 20:39:21 GMT

POSTED FOR A COLLEAGUE(see sig)

I'm looking for a version of the XDR library for 386 based MSDOS machines.
My compiler is Borland C/C++ 3.1 and I'm running Windows 3.1, under MSDOS 5.0.
So far I've had no luck tracking this down, so if you know where the library
exists in either executable or source form (preferred), please contact me.

I find this strange, especially as the XDR library was released to the
public domain by Sun MicroSystems way back in 1987.

I've tried several places so far: MKS, Greenleaf, and Austin Code Works.
BTW, Austin's phone has been disconnected.

Please send responses directly to lvw@tornado.kodak.com
OR post directly to this newsgroup.

Thanks!

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Lyndon C. VanWagner				Eastman Kodak Company
Contract Programmer				Kodak Apparatus Division
Analysts International Corp.			Bldg 11, MS 306004
205 St. Paul Street				901 Elmgrove Road
Rochester, NY 14604				Rochester, NY 14653-6004
(716) 325-6640					(716) 726-0147
===========================================================================
		Inet: lvw@tardis, lvw@tornado.kodak.com
===========================================================================
Excuse me, but why does God need a starship?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++





Newsgroups: comp.lang.c
From: atbowler@thinkage.on.ca (Alan Bowler)
Subject: Re: C vs. FORTRAN
Organization: /etc/organization
Date: Fri, 4 Sep 1992 23:56:18 GMT

In article <DWISEMAN.92Sep3164036@spsd630a.erim.org> dwiseman@spsd630a.erim.org (Dave Wiseman) writes:
>
>Help!
>
>I have a (two) simple programs, one in fortran, and one in C.  I have compiled
>them both optimized, and timed the results.  The fortran version takes .1 s
>to run, and the C version takes 12.5s to run.  I know (hope) that there is a
>simple remedy for this.  The project that I am working on has to do many 
>sines and cosines, and I'd prefer to keep the entire program in C, and not
>mix the languages.  What can I do to improve the speed of the C version?

Fortran compilers are allowed to "know" that DSIN and DCOS are
"special" and have no side effects.  It looks like the optimizer
looked at your fortran do look and replaced it with i = 1000001.
I.e. it never actuially bothered to do the computations.  Try
passing the computed values to another (separately compiled) subroutine
so the compiler thinks the values are actually used.
Newsgroups: comp.lang.c
From: cee1@ra.msstate.edu (Charles Evans)
Subject: Dropping a n from a fprintf()
Organization: Mississippi State University
Date: Fri, 11 Sep 1992 05:21:08 GMT

Ok here is the deal.

Reading in from a textfile with one string per line (variable length, but
none _too_ long) Then I want to add some strings on either side of the
read in string and rewrite the new string to a new file line by line. But
there are some probs.. here is what I have:

	FILE *fp1, *fp2; 
	char *item;         /* also tried stuff like char item[20];,
				same results */

....

	while ((fgets(fp1,20,item)) != 0)
	{
		fprintf(fp2,"I found a %s in my pocket\n", item);
	}
...

Ok here is the deal. fgets reads at most 20-1 characters or up to a
newline.. and if it reaches a newline it adds that to the string along with
the \0.. So if on the first line of reading in (from fp1) it had "chicken"
the string in fprintf would be:

   ---------------------------------------- 
   | c | h | i | c | k | e | n | \n | \0 |
   ----------------------------------------
     0   1   2   3   4   5   6   7    8 

but when I printout.. I get this input:
----
I found a chicken
in my pocket
----

I shoots the \n in the fprintf() .. I want it on one line
so how may I ask can i do it.. I know scanf() has a %[^exclude_chars] con-
version.. but printf() doesnt seem to. And if I use gets() .. cant read
from a file
fscanf(fp1,"%s",item)  .. seems to be giving EVERYTIME a Segmentation
Fault (UNIX) in that line. so we went to fgets.. what can I do to get
it all on one line.. thanks

-- 
+--------------------+-----------------------+------------------------+
|  Charles E. Evans  |  cee1@ra.msstate.edu  |  All things are green  |
|    iDLE CHATTEr    |  cee1@MSSTATE.BITNET  |  unless they are not.  |
+--------------------+-----------------------+------------------------+
Newsgroups: comp.lang.c
From: anderss@epx.cis.umn.edu ()
Subject: Re: SEX SEX SEX
Organization: University of Minnesota
Distribution: usa
Date: Wed, 9 Sep 1992 11:48:02 GMT

In <1992Sep5.012630.24416@kpc.com> hollasch@kpc.com (Steve Hollasch) writes:

>vinod@dolomite.WPI.EDU (Vinod K Nair) writes:
>    [drivel that DESERVED to be deleted.  =^]

>    Ok, hands up everybody who DIDN'T immediately know that this had to be
>a posting from a .edu site.

>______________________________________________________________________________
>Steve Hollasch                                   Kubota Pacific Computer, Inc.
>hollasch@kpc.com                                 Santa Clara, California

And I suppose if he got a job tomorrow and began posting from a .com site
there would be no chance he would ever produce the same type of post again.

By the way, I am also anderson@sctc.com  :-)

-- 
__________________

anderss@epx.cis.umn.edu
Xref: sparky comp.lang.c:13354 comp.sources.d:1252 comp.unix.wizards:3852 alt.sources:2022 misc.misc:3277
From: kevin@sherman.pas.rochester.edu (kevin mcfadden)
Newsgroups: comp.lang.c
Subject: swapping two halves of a 16 bit item
Date: 10 Sep 92 19:17:17 GMT
Distribution: na
Organization: University of Rochester


	 I was wondering if anyone out there would know how to do the
following:

		I have two 16 bit words that contain some info.
		The problem is that PC computers write/use this
			data differently than a Sun program does.
		The problem, more explicitly, is that the first and second
			8 bits of each word need to be swapped:

			a1 a2  b1 b2  --->  a2 a1  b2 b1

			a=first word
			b=second word

		The main program is Forth and we have a routine to do
			it in this language but it is too slow for my
			Prof.  We are using CForth which allows C code
			to be integrated into our programs.

	My idea has been to do your normal variable swap making use
of *memcpy and a small buffer in memory. The first problem is
that I do not know if this method is the most efficient way to do
this.  Second problem is separating the the two 16 bit words.  I
think that it can be done by just using memcpy and specifying the
correct mem address.

Please EMAIL any ideas and suggestions to kevin@sherman.pas.rochester.edu

Thanks a bunch,

kevin
From: bx314@cleveland.Freenet.Edu (Joseph J. Gebis)
Newsgroups: comp.lang.c
Subject: Command Line Arguments
Date: 8 Sep 92 17:29:28 GMT
Reply-To: bx314@cleveland.Freenet.Edu (Joseph J. Gebis)
Organization: Case Western Reserve University, Cleveland, OH (USA)
NNTP-Posting-Host: slc5.ins.cwru.edu


	I would like to know how to pass command line arguments in DOS
to a separate function...  I would greatly appreciate if someone
would write an example of a program that passes command line arguments
to a separate function that then prints them on screen.

	Remember, I'm self-taught, and a beginner, so speak slowly
and loudly. :)
	Thank you very much.
Newsgroups: comp.lang.c,comp.std.c
From: gordon@sneaky.lonestar.org (Gordon Burditt)
Subject: Re: strcpy implementation question
Organization: Gordon Burditt
Date: Sat, 5 Sep 1992 06:27:05 GMT

>The source argument (the second argument) to strcpy is declared as 'const
>char *', which states that the routine will not modify the source string.

No, it says it won't modify the source string *USING THAT POINTER*.
It doesn't prevent it from getting at the source through global variables,
destination pointers saved from previous calls, or just generally using
system-dependent methods (the implementation of strcpy() doesn't have
to be portable) to wipe the whole data segment.  

But I'd still consider any implementation of strcpy() that did these
things non-conforming, even without a statement "thou shalt not mess up
unrelated variables".

>> A better example would be the infamous "variable-length struct".
>> You declare something like:
>>	 struct foo {
>>		 int	type;
>>		 ... bunch of other stuff here ...
>>		 char	name[1];
>>	 } *fp;
>>	 char	x[100];
>> and then use it like:
>>	 fp = (struct foo *) malloc(sizeof(struct foo) + strlen(x));
>>	 strcpy(fp->name, x);
>> "name" has supposedly known size.  x has supposedly known size.
>> The compiler probably aligned both of them.  But if the copying stops 
>> at 1 char or 1 word when x contains a 70-char string, I'm going to be 
>> annoyed.  And a lot of programs will break.

>I don't know of a single compiler that guarantees to place two static
>variables which are declared in the same file next to each other.  In other
>words,

This example may be bogus, but not for this reason.  It does NOT assume
that two static variables are next to each other.  (Which two?  There
are only 2 choices, the source string and a pointer.  Neither is the
destination.  And the program couldn't care less about those variables
being next to each other.)  I didn't show the function header, but I 
actually didn't intend that there be any static variables in the entire 
program (global variables wouldn't have been indented - a style convention
you can't depend on everyone using).  The storage allocated by one call 
to malloc() is guaranteed to be contiguous (within itself).  The struct is 
at the beginning of it.  The space allocated by malloc() is guaranteed 
aligned properly.  The space computation guarantees that there's enough
storage for the string that runs off the end of the struct.  If there is 
extra padding inserted in the structure, that just gives extra margin for 
the claim that it won't run off the end of allocated storage.

Ok, what IS bogus about this example?  (1) Running off the end of the
name[] array, but I have assured that there IS enough storage following
it to hold the data.  Is that good enough?  Any other complaints?

					Gordon L. Burditt
					sneaky.lonestar.org!gordon
Newsgroups: comp.lang.c
From: pt@geovision.gvc.com (Paul Tomblin)
Subject: Re: INVERSE CHARACTORS?
Reply-To: pt@geovision.gvc.com
Organization: Not officially GeoVision Systems Inc., Ottawa, Ontario
Date: Fri, 11 Sep 1992 17:22:28 GMT

slack@hpdmd48.boi.hp.com (David Slack) writes:

>could find out how to print INVERSE charactors?  I am working on a menu
>screen in the HP-UNIX invironment and would like to be able to do it 
>without using curses and in ANSI-C.  Any help is appreciated.

Inverse characters are dependant on your operating system, and 
your terminal.  If you don't want to use curses, and you know that all users
of your system are going to be on exactly the same type of terminal, then
just have your program output the sequence of characters that put it into
inverse character mode - presuming it has one.  One way might be to look
into the termcap/terminfo stuff.

Perhaps somebody on on unix or HP specific group might be able to point you
to a reference.


-- 
Paul Tomblin, pt@geovision.gvc.com or {uunet,revcan}!geovision!pt
(This is not an official opinion of GeoVision Systems Inc.)
"Usenet is like Tetris for people who still remember how to read"
 -- Joshua Heller (heller2@husc.harvard.edu) on rec.humor.funny
Newsgroups: comp.lang.c
From: gt@rundart.demon.co.uk (Giles Todd)
Subject: EASY C 
Distribution: world
Organization: Rundart Limited
Date: Fri, 11 Sep 1992 10:21:24 +0000


In article <faivre.716143938@cst02> faivre%cst02.segin.com@relay.prime.com writes:

>That's why I'm wondering if anybody around did experience EASY C or any analog
>pseudo-language.
>What are pros and cons of using it ?

Back in the early eighties, a company produced an accounts package in a
pseudo-C (called CBASE - nothing to do with the cBASE which someone has
posted to this group) created with macros.  This was supposed to make
life easier for BASIC programmers using C.

In addition to the macros, there are a set of programming guidelines. 
E.g. all variables should be static global, never use pointers, an
entire program should consist of only one source module, etc.

It makes life a nightmare for a C programmer trying to maintain the
software.

Giles.
-- 
Giles Todd                      gt@rundart.demon.co.uk (Internet)
Voice: +44 925 33472            Data: +44 925 414696
Rundart Ltd, 5 Brentnall Close, Great Sankey, Warrington, WA5 1XN, UK
From: karl@ima.isc.com (Karl Heuer)
Newsgroups: comp.lang.c
Subject: Re: Help!!! Please Read this message!?!?!?!?!...
Date: 11 Sep 92 23:22:54 GMT
Organization: Interactive Systems, Cambridge, MA 02138-5302

In article <1992Sep11.204518.15450@klaava.Helsinki.FI> wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:
>when I meant to indicate something like this:
>	int foo();
>If I change that phrase into ``or a prototype that specifies an
>unknown argument list'', it might convey the intended meaning better.

Actually, the correct term for that is ``a function declaration that is not
a prototype''.  (And, in the original context, you'd already covered that
in case 1.)

Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint
Newsgroups: comp.lang.c
From: pt@geovision.gvc.com (Paul Tomblin)
Subject: Re: 1992 International Obfuscated C Code Contest winners
Reply-To: pt@geovision.gvc.com
Organization: Not officially GeoVision Systems Inc., Ottawa, Ontario
Date: Mon, 14 Sep 1992 19:01:05 GMT

barmar@think.com (Barry Margolin) writes:
>In article <268@talgras.UUCP> david@talgras.UUCP (David Hoopes) writes:
>>In article <1992Sep10.135002.25527@wraxall.inmos.co.uk> nathan@elberton (Nathan Sidwell) writes:
>>>Landon C. Noll (chongo@hoptoad.uucp) wrote:
>>>As chongo stated, my entry can't be posted from the USA.
>>Why couldn't your program be posted from the U.S?

>I haven't examined it, but I'll bet if you figure out what it does, you'll
>realize that posting it from the US and allowing it to propogate outside
>the US would be a violation of export control laws regarding munitions.

In case David (and others) don't realize the incredibly stupid state of
export restrictions in the US:

The program implements a form of encryption known as the Enigma code.  This
is a simple encryption which has not been considered a useful code since the
Polish and English broke the Germans' version of it in WWII.  It is also
well documented in the literature, and you could probably hack together a
version based on the description in (for example) Scientific American in a
few hours of programming.  However, inspite of all this, it is an encryption
method, and as such would have to be cleared by many US departments before
they could export it from the US.  The rest of the world is probably a lot
more sane about this, and I wouldn't doubt that programmers in the Soviet
Union (as was) could have exported this at will.

-- 
Paul Tomblin, pt@geovision.gvc.com
(This is not an official opinion/statement of GeoVision Systems Inc.)
"There is nothing wrong with making up .signature quotes, but... make *new*
ones." - Apologies to Henry Spencer and D.Sim
Newsgroups: comp.lang.c
From: plfung@eng.ie.cuhk.hk (fung ping lam)
Subject: Should I buy BC++ 3.1
Organization: Faculty of Engineering, The Chinese U. of Hong Kong
Date: Fri, 11 Sep 1992 18:49:07 GMT

I'm quite interested in buying Borland C++ 3.1. Anyone think that it is 
worthwhile in buying it? Do it contains full documentation for windows 
programming? Thanks for your help.
Newsgroups: comp.lang.c
From: kjb@cgl.citri.edu.au (Kendall Bennett)
Subject: Re: General data structure and algorithm C source
Organization: RMIT Advanced Computer Graphics Centre, CITRI, Melbourne
Date: 11 Sep 92 04:32:13 GMT

wright@epx.cis.umn.edu (Mark Wright) writes:

>covered what you'd get in an introductory Data Structures class without all
>the (mostly useless) space-time analysis crap.  Plus, you get a good ANSI and
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

My god. Now I know why most programs written by people like Microsoft et al
are so god damn buggy and slow - because a lot of programmers think this
stuff is useless.

You wouldn't want to use any other sort except quicksort, mergesort or
heapsort for most applications. No-one uses bubble sort. Why? Because someone
went to the trouble to do this 'mostly useless' space-time analysis crap.

What about other data structures? Sure, we all know about binary trees,
AVL trees etc, but a lot of the time these types of data structures dont
fit the bill - so we devise our own. Without some sort of background in
algorithmic ananlysis and design, chances are your new data structure might
not be very efficient. It _IS_ important, and it is a shame that a lot of
people ignore it.

Kind of reminds of the scorn that people have for Z - software systems
_need_ this kind of formal specification, but people just don't see it...

+------------------------------------------+-------------------------------+
| Kendall Bennett                          | Internet:                     |
| RMIT Advanced Computer Graphics Centre   | kjb@citri.edu.au              |
| CITRI Building, 723 Swanston Street      | rcskb@minyos.xx.rmit.oz.au    |
| Carlton Victoria 3053 AUSTRALIA.         |                               | 
+------------------------------------------+-------------------------------+
| CoSysop (Bossman), PC Connection Australia:               +61 3 688 0909 |
+--------------------------------------------------------------------------+
From: tomc@siesoft.co.uk (Tom Crossland)
Newsgroups: comp.lang.c
Subject: file dates
Date: 8 Sep 92 13:46:08 GMT
Reply-To: tomc@siesoft.co.uk
Organization: Siemens Nixdorf Information Systems Ltd.

Can someone explain to me how to read a files date? I have been looking
through the manual pages, but there are a lot missing on the machine I
am using. Basically, I am writing a queue processor, where each job in
the queue is a file in a specific directory. I just need to be able to
process these jobs in chronological order, then move the file to another
directory. Is there an easy way of finding the earliest file in a directory?

Tom.
Newsgroups: comp.lang.c