HDTenEightyP/NetNews huggingface dataset:
From: Josef Moellers <mollers.pad@sni.de>
Subject: Re: A LITTLE BRAINTEASER...
Date: Fri, 14 Aug 1992 13:46:53 GMT
Organization: Siemens Nixdorf Info.Sys. AG, Paderborn, Germany

In <Bswt31.7zC@research.canon.oz.au> andy@research.canon.oz.au (Andy Newman) writes:

>aet@mullian.ee.mu.OZ.AU (bert thompson) writes:
>>hi!
>>
>>i have a small problem that's been bugging for a while now.
>>
>>here's a program that reverses input from the keyboard:
>>
>>main()
>>	char ch = getchar();
>        ^^^^^^^
>	NOT AGAIN!
>>	if (ch == EOF)
>>		;
>>	else {
>>		main();
>>		putchar(ch);
>>	}
>>}
>>
>>the interesting thing about the program is that it uses no data structures
>>(structs, arrays, pointers, etc..), to do its thing. everything is thrown
>>on the stack.

>Another interesting thing about this program is that its broken!

>So how may machines does this work on? Want to run it on something
>without memory protection and let the little sucker recurse and
>recurse...

It'll run perfectly on systems that have signed characters!
EOF usually is -1, so '\377' will expand to -1.

>If that sounds cryptic remember....

>	getchar() returns an *int*, you char may not be able to store
>	EOF (which is v.often a -ve number).

>Should we start a FFP (Frequently Found Problems?)

Why not? I have been thinking about this for quite some time.
More often than not, I find bugs that look too familiar!
We (more or less regularly) do reviews on software that we write. A list
of "things to check" would be very helpfull.

>-- 
>Andy Newman (andy@research.canon.oz.au)		"int - God's own type"
-- 
| Josef Moellers		| c/o Siemens Nixdorf Informationssysteme AG  |
|  USA: mollers.pad@sni-usa.com	| Abt. STO-XS 113	   | Riemekestrasse   |
| !USA: mollers.pad@sni.de	| Phone: (+49) 5251 835124 | D-4790 Paderborn |
Newsgroups: comp.lang.c
From: darcy@druid.uucp (D'Arcy J.M. Cain)
Subject: Re: Macros for ANSI prototypes
Date: Fri, 14 Aug 1992 19:40:33 GMT
Organization: D'Arcy Cain Consulting

robert@isgtec.com (Robert Osborne) writes:
>dave@cs.arizona.edu (Dave Schaumann) writes:
>> In stead of obfuscating your code with macros that turn on and off
>> functio prototypes as the particular compiler requires, wouldn't it be
>> better to simply include one of the tools freely available to
>> automatically massage prototyped code into K&R acceptability.
>
>What if the code needs to be compiled simultaneously on eight
>architecutures; 4 K&R and 4 ANSI?

You may misunderstand what Dave (from *my* understanding) is saying.  Just
because you have an ANSI --> K&R converter doesn't mean that you throw
away the ANSI code.  The K&R code just becomes one of the stages of the
compilation.  For example, a standard compile might be:

    ANSI C --> Assembler --> a.out

but for another system it becomes:

    ANSI C --> K&R C --> Assembler --> a.out

You see the K&R is simply an intermediate stage and is thrown out after
along with the .s and .o files.  How you do this of course is a matter
for you to set up in your own environment.  As an example, I have hacked
Gnu C to allow me to make Minix programs on my ANSI development system.
The flow is:

    ANSI C (.c) --> K&R C (.m) --> Copy to Minix machine (.c) --> Compile

This is all more or less automated.

>Prototype checking is a great debugging tool;  I'd hate to lose it
>just because one of my architectures is K&R.

And there is no need to.

-- 
D'Arcy J.M. Cain (darcy@druid.com)  |
D'Arcy Cain Consulting              |   There's no government
Toronto, Ontario, Canada            |   like no government!
+1 416 424 2871          DoD#0082   |
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: How many malloc's can I use?
Date: 18 Aug 92 12:00:43 GMT
Organization: AND Software BV Rotterdam

In article <1992Aug17.181615.11905@proxxi.se> elias@proxxi.se (Elias M}rtensson (proxxi)) writes:
|Does ANSI C specify the maximum number of malloc calls that can safely
|be made? Can I do a couple of thousand malloc's and still count on
|that everything will work fine? I am not interested in any
|descriptions of the MS-DOS limitations or anything like that. I just
|want to know what ANSI C says.

The standard says nothing about the number of malloc() calls you can do.
This maximum number is highly dependent on the amount of memory installed
on your machine. 

|And does ANSI C specify that largest block of memory that can be
|malloc'ed?

The size of the largest possible block has to fit in a size_t integral
number. (Check your <stddef.h> file ...)

kind regards,

Jos aka jos@and.nl
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: Looking for Polynomial Least-Squares Curve fit func. in C.
Date: 19 Aug 92 08:51:40 GMT
Organization: AND Software BV Rotterdam

In article <1992Aug18.223204.18239@mahendo.jpl.nasa.gov> robert@triton.Jpl.Nasa.Gov writes:
|C gurus,
|	I'm looking for a function that determines a polynomial
|that fits a given discrete set of data.  Any help is
|appreciated.  BTW--It has to be in C.  I can't stand fortran.

You could give it a try with the Lagrange polynomial:

	n        n
        __      ___
        \       | |   
f(x)=   /_  y_i | | (x - x_j)/(x_i - x_j)
       i=1      j!=i


This translates directly into C as:

double lagrange(x, y, n, X)
double *x;
double *y;
int    n;
double X;
{
int    i, j;
double f, p;

f= 0; 
for (i= 0; i < n; i++) {
	p= y[i];
	for (j= 0; j < n; j++)
		if (j != i)
			p*= (X-x[j])/(x[i]-x[j]);
	f+= p;
}

return (f);

}

Note that this function has an exact fit for the sample points given,
but it might behave very strange when applied to points far outside
the range of the sampled (x,y) points.

kind regards,

Jos aka jos@and.nl
Newsgroups: comp.lang.c
From: wkaufman@us.oracle.com (William Kaufman)
Subject: Re: I wish ANSI-C sizeof (void) == 1 (was Re: preprocessing subterfuge)
Organization: Oracle Corporation, Redwood Shores CA
Date: Sat, 15 Aug 1992 04:25:33 GMT
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 <BswME5.6Mp@research.canon.oz.au> greyham@research.canon.oz.au (Graham Stoney) writes:
] 
] When I first heard of GNU C's deviation from the standard with the sizeof type
] 'void', I thought it was a bad idea; but now I hope ANSI will standardise it
] next time around. void * is the natural type to use when you're considering a
] pointer to a chunk of memory that can hold any arbitrary type;

    Yes, that's the problem: it's a chunk of memory, not necessarily a
chunk of char's.  Even though sizeof(char) may be 1 by definition, that
doesn't mean it's a natural unit of memory on every machine.  As chips
come along with more bits-per-computation, a pointer to a char may
become useless (and inefficient) outside the context of a character
string.

] kernel for instance it seems a natural replacement for caddr_t. And any time
] I need to do arithmetic on one, it's always in terms of bytes

    Sorry to start the byte fight again, but the meaning of a byte is
very tenuous, and can't be the basis for a universal pointer, as "void
*" is meant to be.

    To paraphrase someone (Ritchie?), if you want a pointer to char, you
know where to find it.

                                           -- Bill K.

Bill Kaufman,          | "Hush my darling / Be still my darling /
Corporate Lackey       |  The lion's on the phone,..."
wkaufman@us.oracle.com |              -- "The Guitar", They Might Be Giants
Newsgroups: comp.lang.c,comp.programming
From: robert@metropolis.com (Robert Munyer)
Subject: Re: A LITTLE BRAINTEASER...
Organization: Metropolis Software, Inc.
Date: Tue, 18 Aug 1992 09:55:14 GMT

In article <O1ywr*J00@ro-chp.UUCP> chopps@ro-chp.UUCP (Chris Hopps) writes:

> I guess I don't understand what it is you exactly want.  Should the program
> be portable?  What _is_ a data structure to you?  To me recursing and
> saving values on the stack is a data structure, albeit an ugly and not very
> usefull one in this case, it still represents a logical structuring of data.

I think what he wanted was to use only data structures that the compiler
creates AUTOMATICALLY, without being asked, in order to implement the
semantics of the language.  And "ugly" is in the eye of the beholder.

The problem is pretty easy to solve in any language that supports recursion
within multiple threads.  C does not support this, but the Unix environment
does.  Compile these two programs, and then pipe either one into the other:

-------------------- a.c --------------------
#include <stdio.h>
f ()
{ int c = getchar ();
  return c == EOF ? 0 :
         f () || c != '\n' ? (putchar (c), 1) : 1;
}
main () { f (); putchar ('\n'); }
-------------------- b.c --------------------
#include <stdio.h>
f ()
{ int c = getchar ();
  return c == EOF ? 0 :
         c == '\n' ? 1 :
         f () ? (putchar (c), 1) :
         (putchar (c), 0);
}
main () { while (f ()) putchar ('\n'); }
---------------------------------------------

At the shell prompt, you can type either "a | b" or "b | a".  Note that each
process has one recursive function, with one local variable and no arguments.

______________________________________________________________________
Robert Munyer            |   "I may be synthetic, but I'm not stupid."
robert@metropolis.com    |      -- Bishop, _Aliens_

Newsgroups: comp.lang.c,comp.programming
From: sammy@anagld.analytics.com (Sam Blackburn)
Newsgroups: comp.lang.c
Subject: Re: turboc help please.
Date: 20 Aug 92 02:17:27 GMT
Organization: Computer Sciences Corporation - Systems Engineering Division

tim@shovel.Prime.COM (Tim Cantin) writes:

>I did the same thing when I started coding my first large application.
>This is a common problem... try making several source files, and using a
>project file (.prj) instead of putting everything in one file (messy). Check
>out the manual (or online help) for info on .prj files or 'make' (f9 key).

I'm glad I'm not the only one who ran into this little undocumented feature.
I had to give up on PRJ fiels altogether and go with make files.  BC 2.0 
would even go so far as to wipe out my PRJ file!  Real nasty of it.  I haven't 
had any problem running from a make file.  Be sure to use bccx for maximum use
of system RAM.
From: jsanders@symcom.math.uiuc.edu (John Eric Sanders)
Newsgroups: comp.lang.c
Subject: Array of pointers to structures
Date: 17 Aug 92 22:06:00 GMT
Organization: Math Dept., University of Illinois at Urbana/Champaign

I am trying to create a text window that holds the log of some data
coming in from an instrument and allow the user to scroll backwards
to previous data (but not indeffinately, due to memory limitations).
I am having some problems doing this, and could use some help from
the net.c.gurus.

I think that this is the best way of doing it:
I want to create an array of pointers to strings of length n.  The only
way I have found to do this is to make a structure strig, defining it
as a string 

struct strig 
{  char elment[80]; } ;

I then make an array of pointers pointing to this structure.

struct strig *ptr[100];

The idea behind this is that I can shift the pointers in the array
around, without having to move the actual strings in memory.

However, I can't seem to access a particular character, which I need to.
For example, I want to access the 5th character of the 75th line of
data, but *ptr[74].elment[4] = 'n' doesn't seem to work.  Should it?
Do I have a bum compiler?  I was doing some tests and found that
ptr[5]->elment[2] is not equal to (*ptr[5]).elment[2], like the book
I have says it should be.

Am I totally off base here?  Can someone help me please?
If you think that you can help, but can't understand the question
because I have worded it so weirdly, e-mail for a (hopefully) better
explanation.


Reply by e-mail, please.

Thanx in advance
 
-- 
 The Jester (John E. Sanders)       jsanders@symcom.math.uiuc.edu       
 I have finally discovered the method to my madness.  Unfortunately,    
 there is more madness to my method than method to my madness.
From: benjie@quack.sac.ca.us (Andriod)
Newsgroups: comp.lang.c
Subject: C Indent for MSDOS?
Date: 21 Aug 92 20:16:12 GMT
Organization: The Duck Pond public unix: +1 408 249 9630, log in as 'guest'.

Is there any good C indent command for MSDOS?  The indent mode on
brief editor isn't woking as good as the indentor on UNIX.
Ben
.

-- 
     BBB		Benjie Chen
    BCCCB 		benjie@quack.sac.ca.us
    BCCCB		No Axiomatic System Could Produce All Number-
     BBB		Theoretical Truths, Unless It Is Inconsistent.
Newsgroups: comp.lang.c
From: meissner@osf.org (Michael Meissner)
Subject: Re: Is "...", instead of ",..." legal ?
Organization: Open Software Foundation
	<1992Aug13.171210.5669@klaava.Helsinki.FI>
Date: 14 Aug 92 14:39:48

In article <1992Aug13.171210.5669@klaava.Helsinki.FI> wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:

| scott@megadata.mega.oz.au (Scott Humphreys) writes:
| >That is - can I legally declare a function with none or many arguments,
| >or does it HAVE to have at least one argument. 
| 
| Not in C, possibly in C++ (I don't know).  In Standard C you must have
| at least one argument.  (Pre-ansi C and non-standard C may allow for no
| arguments.  I don't recommend doing it.)
| 
| >This came up because gcc version 2.2.2 let me do it,
| >but gave a warning when used with the -pedantic option.
| 
| The language gcc compiles by default is not standard C, and contains a
| lot of extensions.

Actually, GCC added it because many users were complaining that they
couldn't compile stuff on System V.4, since USL added this 'feature'.
--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

You are in a twisty little passage of standards, all conflicting.
From: hchen@shiva (Haiibo Chen)
Newsgroups: comp.lang.c
Subject: Re: Good introductory books on C
Date: 16 Aug 92 23:01:17 GMT
Organization: Los Alamos National Laboratory, NM

In article <1992Aug7.130006.19419@icf.hrb.com> els@icf.hrb.com (Eric L. Schott) writes:
>In article <1992Aug1.210951.1754@amhux2.amherst.edu>, twpierce@amhux1.amherst.edu (Tim Pierce) writes:
>> In article <1992Jul30.193115.4513@puma.ATL.GE.COM> rsnyder@atl.ge.com (Bob Snyder) writes:
>> 
>>>I'm looking for a good introductory book on learning C.  I've dabbled a bit
>>>with it, and own K&R, but that really isn't a good tutorial text. :-)
>> 
>> K&R is not an easy first text, but you will hardly find a more solid
>> introduction to the language.
>
>I started years ago with K&R.  However, when I started a project using
>ANSI C, I spent many days searching for a good C book.  I found
>_C A Software Engineering Approach_ by Peter Darnell and Philip
>Margolis to be an excellent book.  I highly recommend this book.
>-- 
>
>Eric L. Schott,    HRB Systems, Inc.    814/238-4311     els@icf.hrb.com
>  "As we acquire more knowledge, things do not become more comprehensible
>   but more mysterious."                  Albert Schweitzer, "Paris Notes"

    If one would like to teach C at college or freshmen level, The best Text
 I could have found is

      Gary Bronson & S. Menconi 
       << A First Book of C: Fundamentals of C programming>>
       Second edition 
       West Publisher

     and << Solution Manual with the Book>> 
          By Bronson , Meconi & G. A. Falk ( AT & T)

    West Publish had one popular PASCAL text by NANCY  ( to 4 th edition) 

    This is C book parallel to its PASCAL. 
     Excellent text and self taught book!

Tip: DO NOT buy book blindly when it is first edition. Unless you know.
     However, second edition means this may have some merit. 
Newsgroups: comp.lang.c
From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
Subject: Re: About the 'F' in RTFM
Organization: Texas Instruments Inc
Date: Mon, 17 Aug 1992 16:21:18 GMT

In <7973@ncratl.AtlantaGA.NCR.COM> mwilson@ncratl.AtlantaGA.NCR.COM (Mark Wilson) writes:

>>For the record: I too have an AT&T manual.  There is no index.  The machine
>>which I do a great deal of work on has no man pages.  This sucks.
>>David is right.

>For the record: I too have an AT&T manual.  There is an index.  Just for
>the record I am only familiar with SVR4, I don't know about the previous
>releases.

Well, for the record, I, too, have an AT&T manual.  More than one,
actually.  There is an index (of sorts) in each of them.  The System
Administration book (generic SysVR4), which describes how to do
things, has a 'standard' index in the back of the book.  The System
Administration reference (SysVR4/386), which describes each command in
detail, does not have an Index in the back of the book, but includes a
permuted index prior to the command listing.

Note that the first book (the 'how to do things' one, also describes
how to use the manuals.


-- 
"Insisting on perfect safety is for people who don't have the balls to live
 in the real world."   -- Mary Shafer, NASA Ames Dryden
------------------------------------------------------------------------------
Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
Newsgroups: comp.lang.c
From: banshee@natinst.com (Jeff Kellam)
Subject: Possible Borland 3.1 bug
Organization: National Instruments, Austin, TX
Date: Thu, 20 Aug 1992 16:53:27 GMT

There appears to be a bug in the optimization routines of
the Borland 3.1 compiler.


If the code below is compiled with optimization set to fastest code
a floating point error occurs.

Using the debugger, I was able to determine that the source of the
problem is related to the optimization of -divisor, which is calculated
outside of the loop.  It seems in calculating the value of -divisor,
the compiler doesn't clean up the floating point stack, so after eight
iteration of Function, the FP stack overflows.

If anyone sees a flaw in this reasoning, or has had similiar experiences,
please post or email me at banshee@natinst.com


Thanks,

Jeff Kellam
banshee@natinst.com


/*   PROGRAM STARTS  */

double array[5] = {1.0,2.0,3.0,4.0,5.0};

void Function(double);

main() {
	int i;

	for (i=10; i<20; i++)
		Function(i);
	return 0;
}

void Function(double divisor) {

	int i;

	for (i=0;i<5;i++) {
		array[i] *= divisor;
		array[i] *= -divisor;
	}
}

/*  PROGRAM ENDS  */
Newsgroups: comp.lang.c
From: simon@giaec.cc.monash.edu.au (simon shields)
Subject: wanted matrix optns in c
Keywords: matrix c routines
Organization: Monash University, Melb., Australia.
Date: Thu, 20 Aug 1992 01:27:21 GMT


I was wondering if anyone could tell me where I could get hold of some
c routines to do matrix operations. I am particularly after an inverse
matrix routine to help in solving simultaneous equations. 

I am using matrices in writing least squares programs, error ellipses
etc..

I am using Turbo C++ and unix c.

Thanks

bye from simon
Newsgroups: comp.lang.c
From: holger@zelator.in-berlin.de (Holger Lesch)
Subject: XOpen gencat, catopen.. for sgi IRIS INDIGO ?
Organization: Puplic-Access-Xenix-System
Date: Sun, 23 Aug 92 10:48:39 GMT


Hi there!

I'm looking for the XOpen nls-package (language independent message
catalogs) including gencat, catopen, ... for the sgi IRIS Indigo with
IRIX 4.0.1. May this be avialable as source or from sgi ?

thanx in anticipation

Holger
-- 
#############################################################
# Holger Lesch              email (privat) :                #
# Sybelstrasse 23               holger@zelator.in-berlin.de #
# W-1000 Berlin             email (non-privat):             #
# Tel. (030) 3243615                   holger@kom.sietec.de #
#############################################################
From: swanger@ducvax.auburn.edu
Subject: Sort help needed
Organization: Auburn University, AL
Date: Wed, 12 Aug 1992 20:41:30 GMT

I am writing a program in C.  I have an array of character strings that
I want to sort (I dynamically allocate the "array" with a series of
calloc statements, so to the purist I suppose it isn't really an array,
I just pretend like it is one).  The array usually contains around 1800
strings of 512 characters each.  I sort the array (sort the pointers
actually) with the following sort routine (on a SUN IPC Sparcstation)
and it usually takes 8 to 10 seconds to finish.  Maybe I am too spoiled
or impatient or something, but I really wish that I could speed this
sort up.  If any of you have any tips, functions, ideas, etc. regarding
sorting, I would really appreciate hearing them!

Maybe I should add that many of the character strings only contain a
few characters and are padded with blanks to the "right".  Since each
string is 512 characters, would the sort speed up if I realloced each
string to it's shortest length?  Some of the strings are really long,
so I originally set the default line length for all of the strings to
512, but many of them don't have to be this long.

Thanks in advance,


------------------------------------------------------------------------

void sort_strings(strings, num)
char *strings[];
int num;
{
   char *temp;
   int top, seek;

   for (top = 0; top < num-1; top++)
   {
      for (seek = top + 1; seek < num; seek++)
      {
         if (strcmp(strings[top],strings[seek]) > 0)
         {
            temp = strings[top];
            strings[top] = strings[seek];
            strings[seek] = temp;
         }
      }
   }
}
-- 
David Swanger,   Auburn University, Alabama,   swanger@ducvax.auburn.edu
From: erik@pdnfido.fidonet.org (Erik VanRiper)
Newsgroups: comp.lang.c
Subject: Re: Convert float to a string ?
Date: 23 Aug 92 02:10:13 GMT
Followup-To: poster
Organization: The Source for Source Pub Access Unix

In article <chupchup.714358437@piggy> chupchup@ferkel.ucsb.edu (Robert Earl) writes:
>prem@prem.lbl.gov (Shirdi R. Prem) writes:
>
>| In article <1992Aug20.172112.1564@tin.monsanto.com> bcschu@skws02.monsanto.com (Brett Schultz) writes:
>| >prem@prem.lbl.gov (Shirdi R. Prem) writes:
>| >: In article <1992Aug19.204417.13500@tin.monsanto.com> bcschu@skws02.monsanto.com (Brett Schultz) writes:
>| >: 
>| >: 	   sprintf(b,"%f\0",a);
>| >: 		     ^^^^^^
>| >: 
>| >: 	Are you sure you need a '\0' here............???
>
>| >Let me know if sprintf puts one there anyway, I wasn't sure.
>
>| 	Yes. It does.
>
>No, it does NOT put one there - the '\0' is implicitly provided by the
>C compiler whenever you mention a "..." double-quoted string.  sprintf
>does check for the NUL, however, when reading the format string.  Once
>it reaches the NUL and copies it to the target string (in this case,
>b), it stops.
>
>If you were to somehow pass a non-NUL terminated string to sprintf, it
>would likely go off into never-never land, copying arguments and
>trying to find the zero character.  But '\0' is guaranteed to
>terminate any string literal compiled into a C program, therefore the
>strings are valid input to library functions such as sprintf.

Just to make an already dull conversation duller <grin>...  In the example
above, (sprintf(b,"%f\0",a);), it does not matter if the \0 is after the %f,
in the case of your argument above.  You could still manage to pass it a non-
null terminated string, and it will happily barf all over the place.  If I
remember correctly, things are evaluated left to right, so the string will 
attempt to be placed into b, then terminated with the \0.  If the string
being passed (a) is not null-terminated, the the \0 within the quotes becomes
a waste of space, so to speak.  :-)

I think we are arguing the same side here, but I figured I would stick in my
2 cents to clear things up in my own demented way.  

Enjoy the rest of your weekend.




-- 
Like wow...  This be a .sig, eh? 
GEEKS Anonymous - Join today!
The Source for Source - Pub Access Unix.  (516) 968-7824 or (516) 666-5877
Newsgroups: comp.lang.c,comp.programming