HDTenEightyP/NetNews huggingface dataset:
From: tsv@dbrus.Unify.Com (Tim Vannaman)
Newsgroups: comp.lang.c
Subject: Re: free() problem ...
Date: 11 Sep 92 14:06:39 GMT
Organization: /usr/lib/news/organization

In article <79398@ut-emx.uucp> wangyu@ccwf.cc.utexas.edu (Yu Wang) writes:
>Hello guys,
>
>I got a question on free().  It looks to me that free() doesn't
>actually make freed memory spaces available to other programs.
>
>I wrote 2 simple programs: the first one was to allocate, say, a 10MB
>size array, then, free it (using free()), and put in an infinite
>loop.  After running the first program in background, I ran the
>second program which used malloc() to grab as much memory as possible
>and report the memory size that had been seized.
>
>I ran the second program many times during a long period of time, but
>the available memory size I got from it was always 10MB less than the
>number I got from running the second program prior to the first
>program, i.e. 10 MB memory was never made available to other programs!
>
>Any help is greatly appreciated.
>
>Lena

Have you tried allocating memory again in the first program?  What I think
is happening is that the memory is freed, but is then only available for 
the program that alloc'd it in the first place.

Tim.
--
Tim Vannaman, Premium Technical Support Engineer   Phone: (916) 928-6433
Unify Corporation, Sacramento, California    Fax: (916) 928-6403
tsv@unify.Com  or  {{ucdavis,csun,lll-crg}!csusac,pyramid,sequent}!unify!tsv
Newsgroups: comp.lang.c
From: fjh@mundil.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Command Line Arguments
Organization: Computer Science, University of Melbourne, Australia
Date: Wed, 9 Sep 1992 05:00:56 GMT

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

>	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.

#include <stdio.h>

void print_args(int argc, const char **argv) {
	int i;
	for (i = 0; i < argc; i++) {
		printf("%s%c", argv[i], (i + 1 < argc) ? ' ' : '\n');
	}
}

int main(int argc, const char **argv) {
	print_args(argc, argv);
	return 0;
}
 
-- 
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: "jeff zeitlin" <jeff.zeitlin@execnet.com>
Newsgroups: comp.lang.c
Subject: cobol comp-3 to dbl
Date: 8 Sep 92 22:37:12 EST
Reply-To: "jeff zeitlin" <jeff.zeitlin@execnet.com>
Distribution: comp
Organization: Executive Networks Information

IN MESSAGE <1992Aug31.174651.14828@thinkage.on.ca>, Alan Bowler writes:

AB::>In article <1992Aug26.151021.4445#afs.com> jack@afs.com (Jack Brasch) write
  ::>>Could someone point me in the right direction or mail me a routine to
  ::>>convert COBOL COMP-3 types to a double.

AB::>The starting point would be the Cobol programmer's guide for your
  ::>particular Cobol implementation.  Somewhere in there it should tell you
  ::>exactly what COMP-3 is for that Cobol implementation.  The starnadrds
  ::>only say that you can do arithemetic on comp-N items.  What the -N
  ::>produces on your hardware varies with every Cobol compiler.  It is not
  ::>unlikely that comp-N means different things to different compilers on
  ::>the SAME hardware.  (I have seen this several times.)  When you know
  ::>what the hardware is doing with comp-3 on this Cobol compiler, figuring
  ::>out how to convert to a C double should be straight forward.  At worse
  ::>you can move it to a DISPLAY item, and let the C code call strtod().

  As I understand it, the definition of COBOL says that data names
  defined as USAGE IS COMPUTATIONAL-3 are stored in what IBM calls
  packed decimal format.  In this form, there are two digits per
  octet, except that the last octet contains one digit and a sign
  indication.  The decimal point is not explicitly stored.

  Example:  The number 12,345 would be stored as
  octet       1    2    3
  contains   12   34   5F

  where the sign nybble contains a B or D if negative, A, C, E, or F
  if positive.  In my example above, the octets are numbered from
  most significant to least significant.

  NOTE: the numbers 1.2345, 123.45, 1,234.5, .12345, \et cetera\ would
  be stored identically.  It is the responsibility of the program to
  interpolate the decimal point.

  The only thing you should have to know about the original program is
  a) are these numbers stored big-endian or little-endian, and b) how
  many octets are allocated (i.e. is there any zero padding to a
  specific length).

  J/
  jeff.zeitlin@execnet.com

 * OLX 2.2 * WARNING ! SAFESEX.ZIP is a Trojan
--
Executive Network Information System  (914) 667-4567
International ILink Host
Xref: sparky comp.lang.c:13695 comp.lang.pascal:5408 comp.lang.misc:3086
From: wilson@mailhost.aa.cad.slb.com (David Wilson)
Newsgroups: comp.lang.c,comp.lang.pascal,comp.lang.misc
Subject: Re: Opinions on case sensitivity in programming languages?
Date: 15 Sep 92 18:03:13 GMT
Organization: Schlumberger CAD/CAM; Ann Arbor, Michigan (USA)

In article <3274@isgtec.isgtec.com> robert@isgtec.com (Robert Osborne) writes:
>art@world.std.com (Al Thompson) writes:
>> Case insensitive all the way.  A cat is the same animal as a cAt.
>
>cat ==> small furry animal.
>CAT ==> Computer Aided Tomography.
>
>Case sensitive all the way.

People like what they are accustomed to.  And then they rationalize.  There
is no profound answer to be had on this issue.

Dave Wilson
Newsgroups: comp.lang.c,comp.lang.c++
From: thor@arrakis.denver.co.us (Robert B. Hood)
Subject: cBASE - Part 4 of 4
Summary: A dBASE III+ Class in C++
Reply-To: thor@arrakis.denver.co.us
Organization: Bob's Programming Paradise, Lakewood, CO, USA
Date: Thu, 10 Sep 1992 13:46:17 GMT

--------------------------- COUNT.CPP ---------------------------
// COUNT - A program to test the dBASE III+ C++ class
//                Copyright (C) 1992 Bob Hood
//
// Author      : Bob Hood (thor@arrakis.denver.co.us)
// Last Update : 08.01.92
// Header Files: cBASE.HPP
// Comments    : Class is still under construction, so use at your own risk.
//
//               You are free to copy and distribute this code as long as
//               you do not charge a fee for it, and the Copyright notice
//               above remains intact.

#include    <stdio.h>
#include    <iostream.h>
#include    <conio.h>
#include    <stdlib.h>
#include    <fcntl.h>
#include    <io.h>
#include    <alloc.h>
#include    <string.h>
#include    <mem.h>

#include    "cbase.hpp"

void main(int argc,char *argv[])
{
    int         x,y,z;
    dBASE       *db;                // dBASE object
    FIELD_DATA  *this_field;

    db = new dBASE;                 // create an arbritrary dBASE object

    if((x = db->activate("miscell.dbf",NULL)) != NO_PROBLEM)
    {
        switch(x)
        {
            case DOS_OPEN_ERROR:    cout << "Error opening \"miscell.dbf\"\n";
                                    break;

            case DOS_READ_ERROR:    cout << "Error reading \"miscell.dbf\"\n";
                                    break;
        }

        delete db;
        exit(1);
    }

    if(db->goTop() < 0)
    {
        cout << "\n(** goTop() failed **)\n";
        delete db;
        exit(1);
    }

    cout << "Count occurances of \"" << argv[1] << "\"\n\n";

    x = 0;

    while(!db->eof())
    {
        this_field = db->getField("assign_to");       // get ASSIGN_TO
        if(strncmp(this_field->data.text,argv[1],strlen(argv[1])) == 0)
        {
            ++x;
            cout << x << "\r";
        }
        db->skip();
    }

    cout << "\n" << x << " total of " << db->lastRecord() << " records.\n";
    delete db;          // initiate the destructor to shut it down.
}


----------------------------- COUNT.CPP --------------------------

-- 
Bob Hood    thor@arrakis.denver.co.us     H: 303-980-8392  W: 303-632-2180
---------------------------------------------------------------------------
When people are free to do as they please, they usually imitate each other.
Newsgroups: comp.lang.c
From: gmr6139@ultb.isc.rit.edu (G.M. Richard )
Subject: Re: Help!!!  Please Read this message!?!?!?!?!...
Originator: gmr6139@ultb
Organization: Rochester Institute of Technology
Date: Tue, 15 Sep 1992 00:16:22 GMT


Hello, it's time for an update to answer a few questions.
I found I can use the TCC "hand-compiler" to compile floats, and they
work just fine.  So, it's not an incompatibility with  my computer.  I
put everything onto another computer, and had no problems, with the same
config file, so it wasn't the config file.  By the way, it's version 2.0
I've been trying to get to work.  I also tried version 1.0 on my
computer without luck- it gave me an undefined something, which I didn't
recognise (it looked like random ascii garbage).  This one also worked,
before I zipped it up.  I'm about to just give up and use GCC on the
VAX- this is just giving me hell!  Thanks for all your help, anyone who
has made suggestions.

Permanately Perplexed,
-- 
  _  _                __                         gmr6139@ultb.isc.rit.edu
 /| /|  __  _/__/_   /__) ' __  /_  __ ,_  __/  gmr6139@george.cs.rit.edu
/ |/ |_/-/__/__/____/ \__/_/___/ /_/-/_/__/_/  gmr6139@ritvax.isc.rit.edu
____________________________________________  gmr6139@ritlav.isc.rit.edu
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c
Subject: Re: How can one make a dynamic array?
Date: 7 Sep 92 05:59:06 GMT
Organization: Comp Sci, RMIT, Melbourne, Australia

In article <aphaswan.1.0@cs1.uct.ac.za>, aphaswan@cs1.uct.ac.za (AK PHASWANA) writes:
> Most sorting procedures like bubble sort, bisection method, merge sort,
> use arrays.

Only the versions that are set up to sort arrays.
Bubble sort (does anyone ever _use_ it other than as a horrible example of
what _not_ to do), insertion sort, selection sort, heap sort, quick sort,
merge sort, all work perfectly well with linked lists.  About the only
well-known sorting method that even begins to be tricky with lists is
Shell sort.  I haven't heard of any sorting algorithm called "bisection
method", how does it work?

> The problem with arrays is that they are not dynamic.

Only in antique languages like C and Pascal.  Earlier languages like
Algol 60, PL/I, and Algol 68 let you declare arrays whose size is not
known until run-time.  Newer languages like Ada, Fortran, and GNU C (the
language implemented by GCC) also allow this.  For example, in GNU C you
can write

	void sort(int n, EltType a[]) {
	    auto EltType work[n];
	    ...
	}

Even in C you can use malloc() to make an array of whatever size you want
(apart from addressing problems on i8086-based machines):
	void sort(int n, EltType a[]) {
	    auto EltType *work = malloc(n * sizeof *work);
	    assert(work != NULL);
	    ... use work[] ...
	    free(work);
	}
Having to release the storage yourself is a pain and a common source
of errors.  Viva GNU C!  (Come to that, viva Ada!)

> Or is there any way of implementic sorting and searching procedures
> without using arrays?

For many applications you will find one-way linked lists a _superb_ data
structure.  Merge sort in particular (one of the most efficient and
adaptable sorting methods around, demonstrably faster than quicksort)
just loves linked lists.

For searching, you might as well use red-black trees or splay trees or
even AVL trees; as dynamic as you please and O(lgN) lookup and update.
See any good data structures textbook, e.g. Sedgewick's "Algorithms in C".

-- 
You can lie with statistics ... but not to a statistician.
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c
Subject: Re: sscanf and portability
Date: 15 Sep 92 03:49:15 GMT
Organization: Comp Sci, RMIT, Melbourne, Australia

In article <RUJO.92Sep14160231@ulrik.uio.no>, rujo@ulrik.uio.no (Rune J|rgensen) writes:
> If you use types that explicitly define a byte size, e.g.:
> typedef short INT16;
> typedef long  INT32;
> 
> INT16 i16;
> INT32 i32;

This is a recurring pipe-dream.  No amount of _saying_ INT16 will make it so.
The ANSI stndard guarantees that
    [unsigned|signed] char	at least 8 bits
    [unsigned] short		at least 16 bits
    [unsigned] long		at least 32 bits
    sizeof (long) >= sizeof (int) >= sizeof (short) >= sizeof (char) >= 1

If you want
    -- a compact integral type which can hold at least 16 bits
	use short
    -- a _fast_ integral type which can hold at least 16 bits
	use int
    -- an integral type which can hold the size of any declared object
	use size_t
    -- an integral type which can hold the difference between any two
	pointers for which the difference is defined
	use ptrdiff_t
    -- an integral type which can hold at least 32 bits
	use long

If you want something which is _exactly_ 16 bits or _exactly_ 32 bits,
then there is no guarantee that such a thing exists.  Instead of
kluging around with bit sizes, introduce types which correspond to something
in your _problem_.

> How do you preserve portability with sscanf? E.g:
>   sscanf(s, "%hd %ld", &i16, &i32);

There are several ways.  For example,

	#ifdef	MACHINE_ONE
	typedef	short INT16;
	#define SCAN_16 "%hd"
	typedef int INT32;
	#define SCAN_32 "%d"
	#endif
	...
	sscanf(s, SCAN_16 " " SCAN_32, &i16, &i32);

Note that the " " in the format is superfluous, as %d and variants
will skip leading isspace() characters anyway, so it suffices to do

	sscanf(s, SCAN_16 SCAN_32, &i16, &i32);

A much simpler way in many cases is simply to avoid the scanf() family.

	p = s;
	i16 = strtol(p, &p, 10);
	i32 = strtol(p, &p, 10);

Using strtol() it is easy to check for bad data, too.

-- 
You can lie with statistics ... but not to a statistician.
Newsgroups: comp.lang.c
From: faivre@cst02.segin.com (Denis Faivre)
Subject: EASY C
Reply-To: faivre%cst02.segin.com@relay.prime.com (Denis Faivre)
Organization: Segin, Groupe Axime
Distribution: comp
Date: 10 Sep 92 09:10:45 GMT

What is EASY C ? How valuable is it ?

As far as I know, it consist in a set of #defines supposed to enhance
lisibility, coding and debugging of programs. For instance, braces are
#(re)defined as BEGIN and END, | as BOR (binary OR), || as OR, etc.

Did somebody around experienced such a technique ? What do you think
about it ?

-- Denis.

-- 
Denis FAIVRE - AXIME                   When anything can go wrong, it w$*& !
Phone : +33 20.60.79.79
E-Mail : faivre@cst02.segin.com
From: karl@ima.isc.com (Karl Heuer)
Newsgroups: comp.lang.c
Subject: Re: Sets in C
Date: 11 Sep 92 23:04:45 GMT
Organization: Interactive Systems, Cambridge, MA 02138-5302

In article <1992Sep11.165838.3382@taumet.com> steve@taumet.com (Steve Clamage) writes:
>The C Standard allows an implementation to restrict the size of
>bitfields to the size of an int.

This is true, and possible a correct response to the immediate parent of your
article, but somewhere along the thread some confusion seems to have seeped
in.  The original article was asking about implementing sets, and oversized
bitfields wouldn't address that anyway.%

It *is* true that you can have more than 32 single-bit fields in a struct, and
this would be a way to implement sets as long as you only need to test for
constants:
	struct FruitBasket { unsigned apple : 1; unsigned orange : 1; ... };

But since it's illegal to have bitfield arrays (sigh), I think it's more
likely that one or more of the people who used the term "bitfield" were
actually talking about doing the operations on ints:
	typedef unsigned long Set;
	#define test(s, x) (((s) & (1<<(x))) != 0)

I believe it's already been noted that this model can be extended to sets over
a larger universe by using an array of an integral type.

Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint
________
% Unless someone is incorrectly assuming that struct{int:100} would give you
  a BigNum that you could shift and mask like a normal-sized int.
From: jwarner@mrcnext.cso.uiuc.edu (Jack E. Warner)
Subject: BeginComment / EndComment
Organization: University of Illinois at Urbana
Date: Mon, 14 Sep 1992 20:31:35 GMT

BeginComment
Does anyone /* out there */ know how to comment out a big chunk of code 
/* including several comments */ with some sort of function definition so
that BeginComment in my example is a BIG "/*" and EndComment is a BIG "*/"? 
EndComment

Thanks for responding via email to jwarner@mrcnext.cso.uiuc.edu
Jack.

Newsgroups: comp.lang.c
From: lappala@cse.unl.edu (Kristopher Lappala)
Subject: fseek() and binary files???
Summary: fseek()) and binary files????
Keywords: fseek(),binary
Organization: University of Nebraska - Lincoln
Distribution: global
Date: Tue, 15 Sep 1992 06:49:30 GMT

I am using the fseek() command to read in selected bytes from a
binary file.  Is there an easy way to have my program detect the
length of the file or the end of the file so it knows to stop?
Does the EOF comparison work on binary files?
Thanks for any help.

					K. Lappala

Newsgroups: comp.lang.c
From: atbowler@thinkage.on.ca (Alan Bowler)
Subject: Re: file dates
Organization: /etc/organization
Date: Wed, 9 Sep 1992 21:10:12 GMT

In article <1992Sep8.134608.1255@siesoft.co.uk> tomc@siesoft.co.uk writes:
>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?
>
I suggest that you ask this in a group specific to your operating
system.  When you do be specific about what dat/time you mean.
Different operating systems mainatin a number of different date/time
stamps for each file.
   - when the file was created
   - when the attributes (name, permissions etc) were last changed
   - when the content was last changed
      - This may instead be when the last user that opened it for write
        closed it
      - It may also be when the last user that opened it for write and
        actually wrote somthing closed it
   - when the file was last saved
For a number of systems this information will not be available to an
unprivileged program.  
Also be aware the for some systems (most classical Unix systems
included), gathering this information in the obvious manner
(walk directory and stat'ing every file) may be O(n^2) in the number of
files in the directory.  I have frequently seen cases where time spent
picking the next file took much longer than processing it.
Newsgroups: comp.lang.c
Subject: JModem Source
From: Craig.Humphrey@comp.vuw.ac.nz (Craig Andrew Humphrey)
Date: Tue, 8 Sep 1992 08:27:43 GMT
Organization: Victoria University of Wellington. New Zealand
Keywords: modem jmodem c source


__________________
I'm trying to convert a C source for Jmodem from MSC (or TC I think) to Unix C.
But I'm coming across all sorts of problems, most i've managed to get around
(note: that I don't say they're fixed!) But now I find that it's using interrupts,
and I don't think these are implimented in Unix C (Unix BSD4.3 HP300, CC is 1.40)

Can anyone give me a hand, or does anyone have source for JModem that _will_ port
to Unix.  I already run sz/rz but find the throughput is considerably less than
normal. ie from PC to local bbs ~230cps on Zmodem (GSZ -> BBS) but PC to
University machine dial in, ~180cps on Zmodem (GSZ -> RZ).
Note SZ/RZ is ver 3.03  is there a newer version?

Any other file transfer sources would be of interest.

Thanks

-- 
-----------------------------------------------------------------------------------
|Craig Humphrey.     chumphre@comp.vuw.ac.nz        | The above opinions in no way |
|                    HUMPHREY_C@kosmos.wcc.govt.nz  | represent those of any sane, |
|Victoria University Wellington,  New Zealand.      | normal person, I hope!       |
Newsgroups: comp.lang.c
From: steve@taumet.com (Steve Clamage)
Subject: Re: Portable Varargs?
Organization: TauMetric Corporation
Date: Wed, 9 Sep 1992 15:17:30 GMT

hollasch@kpc.com (Steve Hollasch) writes:


>    Is there a portable way to do variable argument functions that will
>also work on ANSI C compilers as well as standard K&R C compilers?  Right
>now it looks like varargs.h and the accompanying macros works on the
>platforms I've tried, but was wondering if I can assume that this utility
>will work on all "reasonable" platforms.

Variable-argument functions may be implemented in many different ways
by compilers.  For this reason, you can't rely on any particular
set of macro definitions to be portable, by which I mean you can't
carry around your own varargs.h or stdarg.h header file and expect
it to work with an arbitrary C compiler.

A C compiler will provide its own version of one or both of those header
files which, one can only assume, will work correctly with the compiler.
If you stick with use of the compiler-supplied header file and the
usual macros, you should be all right.

Unfortunately, the macros in varargs.h and stdarg.h are not compatible,
and many compilers have one header but not the other.  The method
of declaring/defining a variable-arg function also depends on which
set of macros you use, further complicating the issue.

If you are lucky, all the compilers you need to use will support
the Standard C <stdarg.h> and allow Standard C function prototypes.
One hopes that more and more compilers, even if remaining backward-
compatible, will support, or at least allow, Standard C features.

Otherwise, you will have to use #ifdef's around function declarations,
headers, and macro usage.  This makes the code nearly unreadable.
On the plus side, such functions tend to be rare, so you don't have
to deal with this often.

I don't recommend using varargs.h exclusively, since it will make
porting the code to Standard C environments more difficult, and
because varargs.h cannot be used with C++ at all.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16
Xref: sparky comp.lang.c:13641 comp.lang.pascal:5394 comp.lang.misc:3067
From: stephan@blade (Stephan Eggermont)
Newsgroups: comp.lang.c,comp.lang.pascal,comp.lang.misc
Subject: Re: Opinions on case sensitivity in programming languages?
Date: 14 Sep 92 15:15:02 GMT
Followup-To: comp.lang.c
Organization: MCGV Stack, Eindhoven University of Technology, the Netherlands.
X-Newsreader: Tin 1.1 PL4

robert@isgtec.com (Robert Osborne) writes:
: art@world.std.com (Al Thompson) writes:
: > Case insensitive all the way.  A cat is the same animal as a cAt.
: 
: cat ==> small furry animal.
: CAT ==> Computer Aided Tomography.
: 
: Case sensitive all the way.

CIT ==> Computer Inflicted Tunnel-vision. :-)

There are way to much TLA's to allow programmers to use them as names for
variables. As Sewell explains in his book on WEB, names with capitals in them
don't get typesetted well. If you want your programs to look right, you have
to use underscores. (computer_aided_tomography) You might want to use an
intelligent editor which knows which names of variables you allready used
(context-sensitive).

Stephan
stephan@blade.stack.urc.tue.nl

Newsgroups: comp.lang.c
From: silvia@rcf.rsmas.miami.edu
Subject: Dgroup
Reply-To: silvia@rcf.rsmas.miami.edu
Organization: RSMAS
Date: Sat, 5 Sep 92 23:46:56 GMT

Does anyone have a simple way of increaseing the Dgroup environment variable. From 64 to say 128? This is a dumb question but I seem to be stumped. Help!
Newsgroups: comp.lang.c,sci.math,comp.lang.misc,comp.lang.fortran,comp.std.c