HDTenEightyP/NetNews huggingface dataset:
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: Thu, 10 Sep 1992 17:04:38 GMT


AS the origional source of this thread, I would like to add a few
thoughts to the swarming mass of posts...

I am using a Tandy 1000 TL/2.  It is a '286 with 640k, and while I have
never had compatibility problems before, does anyone suppose this could
get in my way?  It's a true 80286 chip, however it has an 8-bit bus
bolted onto it.  Does Turbo C require full 16-bit or 32-bit architecture
to compile real numbers?  Turbo Pascal never gave me problems, however
Pascal is much different from C.  The actual programs are written in a
related way, because TSR programs written for TP also work for TC.

If this the case, for whatever hardware reason, is there any way to
force TC to use an 8088 set or an 8-bit set of instructions?  

Eternally Perplexed,


-- 
  _  _                __                         gmr6139@ultb.isc.rit.edu
 /| /|  __  _/__/_   /__) ' __  /_  __ ,_  __/  gmr6139@george.cs.rit.edu
/ |/ |_/-/__/__/____/ \__/_/___/ /_/-/_/__/_/  gmr6139@ritvax.isc.rit.edu
____________________________________________  gmr6139@ritlav.isc.rit.edu
Newsgroups: comp.lang.c
Newsgroups: comp.lang.c
Subject: Re: bogosort revisited (with source)
From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
Date: 8 Sep 92 16:18:53 GMT
 <1992Sep6.111107.16924@grebyn.com> <1992Sep6.164314.14858@athena.mit.edu>

In <1992Sep6.164314.14858@athena.mit.edu> tada@athena.mit.edu (Michael J Zehr) writes:

>Okay, deterministic and horrible:

>Generate all sorted lists of length N of numbers drawn from the domain
>of the elements you're sorting.*  (for example, all sorted lists of 2^32
>bit patterns.)  (there are a lot of them, bounded by 2^32^N for this
>example.)** Check to see if the list contains exactly the elements you're
>trying to sort.  (Do this by some O(N^2) algorithm.)

>This is now O(n^2 * K^N) where K is the number of unique elements of the
>data type that the sort will handle.  Furthermore, it's deterministic.

>-michael j zehr

>_______
>* If you want, generate all sets instead of just the sorted one.  Then
>you get horrible space as well as time characteristics!

>** I couldn't quickly come up with the closed form of this expression,
>but I only had about ten minutes to spare.  Can someone else do better?
>It looks really messy after N>3...

 /  2^32 \      (2^32) ! 
|         | = ----------------
 \   N   /    (2^32-N)! N!


(Well, you asked.)
--
Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
My opinions are my own, and do not represent those of my employer.
My interaction with our news system is unstable; please mail anything important.
From: wkaufman@us.oracle.com (William Kaufman)
Newsgroups: comp.lang.c
Subject: Re: extern struct
Date: 10 Sep 92 03:43:30 GMT
Organization: Oracle Corporation, Redwood Shores CA
X-Disclaimer: This message was written by an unauthenticated user
              at Oracle Corporation.  The opinions expressed are those
              of the user and not necessarily those of Oracle.

In article <1428@yetti.UUCP> g-yao@cs.yorku.ca (Ling Yao) writes:
] 
] ----------------file 1------------------------------
] 
] 	static struct point p[100][100];
] 
] -----------------------------------------------------
] 
] ------------------file 2----------------------------
] extern struct point p[100][100];
] ---------------------------------------------------

    "static" means two different things at once:

        1) The item is local to its scope (either file or function), and
    cannot be accessed directly from outside that scope: no extern
    references allowed.

        2) The item has duration: even if it's declared inside a
    function, its value will be consistent between function calls.

    The problem you've got is #1.  The simplest way to deal with this
is:

    - Put the struct declaration and the extern reference in a header
file, included by both file 1 and 2.

    - Put the definition of p *without the "static"* in file 1.

                                           -- Bill K.

Bill Kaufman,          | "...all conscious species are plastic and
Corporate Lackey       |  all plastic species are conscious."
wkaufman@us.oracle.com |                     -- Yew-Kwang Ng
Newsgroups: comp.lang.c
From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
Newsgroups: comp.lang.c
Subject: Re: typedef and memory allocation
Date: 11 Sep 92 15:34:30 GMT
Distribution: usa

In <9225523.27157@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:

>winfree@math.arizona.edu (Art Winfree) writes:

>>typedef double vector[3]

>There should be a semicolon at the end of the above typedef.

>>main()
>>{
>>.
>>.
>>.
>>}
>>
>>funky_func()
>>{
>>vector bigarray[100];
>>.
>>.
>>.
>>}
>>
>>Question: Shouldn't a reasonable C compiler allocate enough
>>(3*100*sizeof(double)) memory for bigarray for use when funky_func()
>>is called? Evidently mine doesn't, since the code core dumps unless I
>>explicitly calloc in funky_func().

>Either your compiler is broken, or there is a bug somewhere else in your code.
>(ie. in the elided part).

>The only other possibility I can think of is that you might just possibly
>be getting a stack overflow, but that seems highly unlikely.

Perhaps your machine crashes when referencing an invalid floating point
value, in which case calloc might also stop the crash (if the all 0 bit
pattern is a legal floating point number).
--
Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
My opinions are my own, and do not represent those of my employer.
My interaction with our news system is unstable; please mail anything important.
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c
Subject: Re: main()
Date: 14 Sep 92 08:00:27 GMT
Organization: Comp Sci, RMIT, Melbourne, Australia

In article <1992Sep11.223347.5184@ima.isc.com>, karl@ima.isc.com (Karl Heuer) writes:
> >Why is there a reluctance to use [EXIT_SUCCESS and EXIT_FAILURE]?
> 
> From my own perspective, it's because they aren't expressive enough -- I
> like to have Unix programs return 0 for "Yes", 1 for "No", 2 for "Bad args"
> (e.g. can't open the file whose name was specified as an argument), 3 for
> "Internal error" (including insufficient memory).

I tend to do this:

#ifdef	USESYSEXITS
#include <sysexits.h>
#else
#define	EX_USAGE	EXIT_FAILURE
#define	EX_NOINPUT	EXIT_FAILURE	/* Heuer's 2 */
#define EX_SOFTWARE	EXIT_FAILURE	/* Heuer's 3 */
...
#endif

<sysexits.h> is a BSD-ism, but it's the nearest thing to a "standard"
set of exit codes, and even though it isn't quite as expressive a collection
as I'd prefer, I decided not to invent my own.
-- 
You can lie with statistics ... but not to a statistician.
Newsgroups: comp.lang.c
From: foxd@silver.ucs.indiana.edu (daniel fox)
Subject: characters from serial port
Organization: Indiana University
Date: Mon, 14 Sep 1992 18:22:47 GMT


Under MS-DOS how does one specify in a C program that one wants characters read
from port COM2 at 19.2K Baud?  I am working on this program using Quick C.

                                      Daniel B. Fox
                                      KF9ET
.standard disclaimer
Newsgroups: comp.lang.c
From: hawkeye@glia.biostr.washington.edu (Ken Keys - TF Dude)
Subject: Re: Initializing Random Seeds 
Organization: University of Washington
Date: Sat, 5 Sep 1992 10:50:33 GMT

In <1992Sep4.173259.12437@maccs.dcss.mcmaster.ca> rickan@maccs.dcss.mcmaster.ca (Mark Rickan) writes:

>Please excuse me if this is a FAQ, but is there a ANSI-compliant means
>of initializing a random seed which has a reasonably low probability
>of recurring? At the moment, I'm using srand in conjunction with
>time(&t). Unfortunately, on a fast machine, the time delay is often
>< 1 second, resulting in the production of the same random value.
>
>I've avoided this problem by use of a time delay, but I'm convinced
>that there must be a more elegant and efficient means of doing this.

One commonly used seed on UNIX systems is time(NULL) + getpid().
By the way, why do you feel the need to seed the generator more than once?
-- 
--
Ken Keys, aka Hawkeye
Master of the Fugue
kkeys@ucsd.edu or hawkeye@ucsd.edu
Newsgroups: comp.lang.c
From: ptran@envmsa.eas.asu.edu (Phi-Long Tran)
Subject: Re: typedef and memory allocation
News-Software: VAX/VMS VNEWS 1.4-b1  
Reply-To: ptran@asuvax.eas.asu.edu
Organization: Arizona State University, Tempe, AZ
Distribution: usa
Date: Fri, 11 Sep 1992 09:31:00 GMT

In article <3687@amethyst.math.arizona.edu>, 
winfree@math.arizona.edu (Art Winfree) writes...

> typedef double vector[3]

> main() { ... }

> funky_func()
> {
> vector bigarray[100];
> ..
> }

> Question:  Shouldn't a reasonable C compiler allocate enough
> (3*100*sizeof(double)) memory for bigarray for use when funky_func() is
> called?  Evidently mine doesn't, since the code core dumps unless I
> explicitly calloc in funky_func().  I know typedef itself doesn't cause
> any allocation, but are typedef'd types, as above, supposed to be
> sizeof'd and variables invoking them given appropriate memory, even if
> included in local function array definitions?

     The answer to the last question is "yes".  But not really for the
reason you suggested.  Typedef's are really just constructs for simplifying
complex type declarations.  Check withe K&R for the actual definition and
meaning of a typedef.  So the compiler will see the declaration of bigarray
as something to the effect of:

     double bigarray[100][3];

Runtime environment needs to allocate 300 double's from the stack.  If a
double occupies 4 bytes, then that's about 1K of memory for the array.  The
call to calloc is probably the way to go.

---
Phi-Long Tran
ptran@asuvax.eas.asu.edu
Arizona State University
From: duong@chestnut.chem.upenn.edu (Duc Duong)
Newsgroups: comp.lang.c
Subject: Need book reference on binary, data type structure..
Date: 10 Sep 92 15:01:04 GMT
Organization: UPENN Computer Graphics Research Laboratory


  hello all..

Could any one recomment me a good book, documents for C, C++ on data type, how to deal with binary data, How to do the conversion from one kind of binary format to another..etc. Where is the FAQ host for this group any way??
E-mail please. Thank you.

						duc
Newsgroups: comp.lang.c
From: tony@nexus.yorku.ca (Anthony Wallis)
Subject: Re: EASY C
Organization: York University
Date: Thu, 10 Sep 1992 10:52:59 GMT

> ..braces are #(re)defined as BEGIN and END, | as BOR (binary OR),
> || as OR, etc.

Another response (especially for British readers) might be ..

Sounds like a load of old COBOLers !

--
tony@nexus.yorku.ca = Tony Wallis, York University, Toronto, Canada
From: karl@ima.isc.com (Karl Heuer)
Newsgroups: comp.lang.c
Subject: Re: INVERSE CHARACTORS?
Date: 11 Sep 92 22:41:45 GMT
Article-I.D.: ima.1992Sep11.224145.5417
Organization: Interactive Systems, Cambridge, MA 02138-5302

In article <15060003@hpdmd48.boi.hp.com> slack@hpdmd48.boi.hp.com (David Slack) writes:
>I am trying to learn to program in C, can anyone direct me to where I
>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.

If you're willing to limit your application to working on screens that use
the ANSI escape sequences, and the ASCII character set, then
	void putinverted(char *s) { printf("\033[7m%s\033[m", s); }
will probably do what you want.  If you're writing a menu application without
benefit of curses (why?), then you're probably already making similar
assumptions anyway.

Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint
From: torek@horse.ee.lbl.gov (Chris Torek)
Newsgroups: comp.lang.c
Subject: exit() values (was main())
Date: 11 Sep 1992 20:19:24 GMT
Organization: Lawrence Berkeley Laboratory, Berkeley
Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
NNTP-Posting-Host: 128.3.112.15

In article <MJN.92Sep10232853@pseudo.uucp> mjn@pseudo.uucp
(Murray Nesbitt) writes:
>In my opinion, the Standards committee broke exit().  Suppose I am
>destitute and morally bankrupt, and decide to program in ANSI C on a
>VAX running VMS to make a miserable living.  How do I explicitly
>return the value 0 to VMS from my program?  VMS aside, how can I now
>be sure I am returning 0 on *any* system?

Since we do not know what 0 *means* on `any system', the ANSI standard
obviously cannot provide some sort of macro for that meaning.  So
consider the VMS-specific case:  If you want to get return 0 as your
program termination status, just call

	_VMS_exit(0);

or some other machine-dependent thing.  (You already bought into
VMS-specificity in the exit *value*, so it should not hurt to emphasize
this in the exit *call*.)

(Personally, I happen to believe that exit(0) should always mean
success and exit(1) should always mean failure, and the fact this
happens to map one-for-one to Unix norms is merely a `lucky break'
for Unix.  Other systems may have to provide a _FOO_exit function...
but they probably have to *anyway*, so who cares if the ANSI exit()
function does not map one-to-one on this function?)

If you want more than just generic `success' and `failure', you are
stuck with system-dependencies.  Best to wrap them in some abstraction
(a header? functions?), and have a fallback that maps everything back
onto `success' and `failure'.
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov
Newsgroups: comp.lang.c
From: tony@nexus.yorku.ca (Anthony Wallis)
Subject: Re: EASY C
Organization: York University
Date: Thu, 10 Sep 1992 10:28:35 GMT

Denis Faivre (faivre@cst02.segin.com) wonders
> What is EASY C ? How valuable is it ?  .. braces are #(re)defined
> as BEGIN and END, | as BOR (binary OR), || as OR, etc.
> .. What do you think about it ?

BEGIN Is this a joke QUESTION MARK   However COMMA to answer your
question ELLIPSIS END

About what you would think of English BEGIN or any other natural
language COMMA for that matter END written like this PERIOD

--
tony@nexus.yorku.ca = Tony Wallis, York University, Toronto, Canada
From: karl@ima.isc.com (Karl Heuer)
Newsgroups: comp.lang.c
Subject: Re: main()
Date: 11 Sep 92 22:33:47 GMT
Article-I.D.: ima.1992Sep11.223347.5184
Organization: Interactive Systems, Cambridge, MA 02138-5302

In article <MJN.92Sep10232853@pseudo.uucp> mjn@pseudo.uucp (Murray Nesbitt) writes:
>In my opinion, the Standards committee broke exit().  Suppose I am [using
>VMS].  How do I explicitly return the value 0 to VMS from my program?

You call sys$exit(0).

Suppose I'm using a system on which the native system call takes a string
argument instead of a number.  (A much better model, I think.)  Should I blame
X3J11 for insisting that exit() doesn't accomodate me?

>Why is there a reluctance to use [EXIT_SUCCESS and EXIT_FAILURE]?

From my own perspective, it's because they aren't expressive enough -- I
like to have Unix programs return 0 for "Yes", 1 for "No", 2 for "Bad args"
(e.g. can't open the file whose name was specified as an argument), 3 for
"Internal error" (including insufficient memory).  For true portability,
I should use different symbolic names for these (and have the non-zero values
all expand to the value of EXIT_FAILURE on sufficiently impoverished systems),
but I haven't gotten around to reorganizing my existing code that way, yet.

Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint
Newsgroups: comp.lang.c
From: mcook@melkur.dev.cdx.mot.com (Michael Cook)
Subject: Re: Help!!! Please Read this message!?!?!?!?!...
Organization: Motorola Codex, Canton, Massachusetts
Date: Tue, 8 Sep 1992 19:05:37 GMT

eletanjm@nuscc.nus.sg (TAN JIN MENG) writes:

>gmr6139@ultb.isc.rit.edu (G.M. Richard ) writes:
>: I can't get my compiler to do float-type variables.

...

>: #define apples  4
>: #define oranges 3.6
>:  
>: main()
>: {
>:         printf("\nApples = %d\nOranges = %f", apples, oranges);
>: }

>Your compiler can't know what orange is... So it assumes that its an
>int. That's why the wrong result. Alternatives ...

What?  Don't be silly...  The compiler knows what orange is.

Matt's problem is probably due to Turbo C trying to avoid linking against the
floating point library (so as to keep the program smaller).  The compiler saw
no "float" or "double" declarations, and so it linked against the non-floating
point version of the standard library, and picked-up the non-floating point
version of printf, which probably doesn't understand %f.

Matt can probably workaround the problem by making a floating-point
declaration somewhere.  Or there may be an option to force Turbo C to link
against the floating-point library.

Michael.
Xref: sparky comp.lang.c:13349 comp.unix.misc:3587
From: drice@ponder.csci.unt.edu (Keith Rice)
Subject: Re: Command Line Arguments
Organization: University of North Texas
Distribution: usa
Date: Wed, 9 Sep 1992 01:55:04 GMT

In <BuABu6.Au5@news.cso.uiuc.edu> gordon@osiris.cso.uiuc.edu (John Gordon) writes:

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

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

Seeing that he posted to comp.lang.c he obviously must mean C!

--
D. Keith Rice -- University of North Texas -- drice@ponder.csci.unt.edu
-----------------------------------------------------------------------
(new .sig construction delayed due to union contract disputes)
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c
Subject: Re: Help to solve problem with "gets()"
Date: 14 Sep 92 07:21:15 GMT
Organization: Comp Sci, RMIT, Melbourne, Australia

In article <1429@yetti.UUCP>, g-yao@cs.yorku.ca (Ling Yao) writes:
> #include <stdio.h>
> 
> static char *message[]={"Translation:",
> 			    "0. X      1. Y    2. Z",
>                         "Exit:",
> 			    "x or X",
> 			 NULL
>                         };
> main()
> {
>     float tmp;
>     int i=0;
>     char *a;
> 
> /* print input message */
>     while(*message[i]!=NULL)
>     {
> 	printf("%s\n",message[i]);
> 	i++;
>     }

message		is an array of pointer to char
message[i]	is a pointer to char
*message[i]	is a char

You should _always_ think of NULL as a pointer.
Remember, an ANSI C compiler may legally #define NULL (void*)0
and it is an error to assign such a value to an integral variable
or compare such a value with an integral value (other than the
constant 0...).

Suppose you have a C system which does #define NULL 0
as it legally may, then the error will go undetected.
It is still a conceptual error.  In particular, none of the elements
in message[] is a pointer to a string beginning with the character NUL.
(Note:  "NUL" is the ASCII mnemonic for the character '\0' and it is
NOT the same as the nil pointer NULL.)  So your loop will end up
looking at *message[i] when message[i] is NULL.
This is called "dereferencing NULL" and on many machines programs
that try to do that are killed.  "Segmentation violation" is a
common runtime error message for that.

In this particular case, I think you want

	for (i = 0; message[i] != NULL; i++) {
	    printf("%s\n", message[i]);
	}

> 
>    L1: gets(a);

A very common mistake that beginning programmers make is to ignore
the return values of things like gets(), fopen(), and malloc().
That return value is telling you something very important.  In
the case of gets(), it tells you whether you got to the end of the
stream.

But the mistake here is that the argument of gets() should be
(a pointer to) an array of characters.  In this case, the variable
"a" has never been initialised.  A good compiler (such as gcc with
the -O and -Wall options) will warn you about that.

The normal way to use gets() is

	char buffer[whatever_size_you_believe_is_big_enough];

	while (gets(buffer)) {
	    -- there is a line in buffer --
	}
	-- now we have reached the end of the stream --

Note that no label is needed, nor any goto.  Indeed, most ways of
reading things from a file look like this in C:

	while (try_to_read_something(...)) {
	    you got something;
	}
	get here on end of file or error;

Really good C programmers don't use gets(); they use fgets() or roll their
own, but that's another story.

-- 
You can lie with statistics ... but not to a statistician.
Xref: sparky comp.lang.c:13604 comp.lang.pascal:5357 comp.lang.misc:3052
From: robert@isgtec.com (Robert Osborne)
Newsgroups: comp.lang.c,comp.lang.pascal,comp.lang.misc
Subject: Re: Opinions on case sensitivity in programming languages?
Date: 12 Sep 92 23:04:39 GMT

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.

Rob.
--
Robert A. Osborne   ...!uunet.ca!isgtec!robert or robert@isgtec.com
Newsgroups: comp.lang.c
From: ted@ocsmd.ocs.com (Ted Scott)
Subject: Re: conversion from char to ascii value
Organization: Online Computer Systems, Inc.  Germantown, Md., 20874
X-Newsreader: Tin 1.1 PL5
Date: Mon, 14 Sep 1992 15:04:58 GMT

Paul Smee (smee@bristol.ac.uk) wrote:
: In article <els337w.716118237@mdw010.cc.monash.edu.au> els337w@mdw010.cc.monash.edu.au (Mr D. Singh) writes:
: >Can anybody please help me with my assignment!!!!!
                                      ^^^^^^^^^^
Does your book have an ascii table in it? Try the index. Then implement
the table in code.
: >
: What problem?  The char IS its ASCII value, once it's in the computer,
: it's all in how you look at it.  (If that's not enough of a hint, think
: about it until it is.)
This is true provided the native machine codes char data as ascii,
but what if you are on another machine? Like oh say IPM.

--

-Ted Scott          
tscott@ocsmd.ocs.com           I was told that I'm a P.C. person:
(301) 601-2252                               Politically Challenged, that is.
Newsgroups: comp.lang.c
From: ptran@envmsa.eas.asu.edu (Phi-Long Tran)
Subject: Re: File Handling
News-Software: VAX/VMS VNEWS 1.4-b1  
Reply-To: ptran@asuvax.eas.asu.edu
Organization: Arizona State University, Tempe, AZ
Date: Thu, 10 Sep 1992 02:25:00 GMT

In article <1992Sep9.173717.22248@nosc.mil>, mitch@nosc.mil (Ray Mitchell) 
writes...

> ...  Assume the typical case where a binary file consists of several
> records (structures).  I wish to write a program in which the user
> specifies which record is to be modified.  My initial approach was to
> simply fseek into the file the appropriate amount then overwrite the
> record at that position.

     You can place a header record at the beginning of the file containing
the number of records in the file.  You would update the record accordingly
when removing or adding records.

---
Phi-Long Tran
ptran@asuvax.eas.asu.edu
Arizona State University
Newsgroups: comp.lang.c