HDTenEightyP/NetNews huggingface dataset:
From: ted.jensen@spacebbs.com (Ted Jensen) 
Newsgroups: comp.lang.c
Subject: Where are literals stored?
Date: 21 Nov 92 06:15:00 GMT
Distribution: world
Organization: SPACE BBS - Menlo Park, CA - 10 Lines + 4gB - 415-323-4193
Reply-To: ted.jensen@spacebbs.com (Ted Jensen) 


In message <1992Nov18.233739.2335#den.mmc.com>
richard@crowded-house.den.mmc.com (Richard Armstrong) writes:

> Are literals always stored in the same location in memory?
> (IBM-PC,Borland)
>
> For instance, is the string a stored in the same place in the
> following two declarations?:
>
> static char a[]="ABC"
> funca()
> {
> }
>
> funca()
> {
> char a[]="ABC";
> }

I am running TC++.  Using my debugger and looking at the assembly
code and data segment in each of these situations I have
determined that, with my compiler:

    The "ABC" is stored in the data segment in both cases. The
    difference will lie in how the compiler treats that which
    lies to the left of the equal sign.  In the first case the
    pointer to the string stored in the data segment is treated
    as a global variable and isaccessible from functions other
    than funca().  In the second case, the value of the pointer
    is hardcoded in the code for the function and stored on the
    stack.  That is, it is a local pointer.

Hope this helps!  Ted Jensen  Redwood City, Calif.


 * SLMR 2.1a * 
                             
Newsgroups: comp.lang.c
From: blume@kastle.Princeton.EDU (Matthias Blume)
Subject: Re: Rounding floating point numbers in C
Reply-To: blume@kastle.Princeton.EDU (Matthias Blume)
Organization: Dept. of Computer Science, Princeton University
Date: Sun, 22 Nov 1992 16:27:04 GMT

In article <1992Nov22.040145.6371@u.washington.edu>,
golbone@stein.u.washington.edu (Sima Hashemifar) writes:

[quote deleted]

|> 
|> No! No! No! You can not in any way deduce the properties of the floating
|> point system based on the rounding behavior. For one, most modern fp
|> units may be convinced to act in many way, affine ...
|> More impotantly, there are elementary rules for rounding in scientific
|> world. Any odd number followed by 5 is rounded down while even numbers
	      ^^^^^^^^^^			  ^^^^
I believe you mixed something here... I know only ``round to even''.

|> are rounded up. Based on this simple rule, the results printed above
|> are not valid in your laboratory notebook.
|> Thanks.
|> BTW, I ran the numbers through my fortran compiler on DEC/Ultrix, I got 
|> the scientifically correct results, BUT the C compiler generated the
|> results above. I can only say that "C" has a different floating point
|> model than Fortran.

Ok, so much for the Fortran vs. C thread... :(

I don't know, what the rounding rule has to do with the original question.
The fact is, that numbers like '1.15' cannot be accurately represented in an
IEEE-like binary representation.  Any sane fp model would choose the
representation that is CLOSEST IN VALUE.  This might be bigger or smaller
depending on the original number.  It has nothing to do with the digit at the
end.  Ties are to be broken, if there are two internal representations which
both are closest in value.
	Similarly, when you print the number with a limited number of digits,
then you should at least choose the EXTERNAL representation, that is closest
to the internal number.  Again, ties are to be broken whenever there is more
than one possible representation.  The disadvantage of this approach is, that
what you print is not necessarely what you've read, even if you are allowed to
use as many digits as the original number in your input had.  (Think about it!)
A better approach is to print something which is guaranteed to reproduce
EXACTLY THE SAME INTERNAL REPRESENTATION when read back.

Two excellent papers about these number converting issues are:
	William D. Clinger: ``How to Read Floating Point Numbers Accurately''
and
	Guy L. Steele Jr. and Jon L White: ``How to Print Floating-Point
	Numbers Accurately''
both to be found in ``Proceedings of the ACM SIGPLAN '90 Conference on
Programming Language Design and Implementation''

-Matthias
Newsgroups: comp.lang.c
From: mike@imcldn.demon.co.uk (Michael P Simkins)
Subject: Possibly daft question but.....
Distribution: world
Organization: Independent Mail Centre, Enfield, Middx
Reply-To: mike@imcldn.demon.co.uk
X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.18)
Date: Thu, 19 Nov 1992 18:55:33 +0000

This is possibly a silly question but here goes....

I have accuired to source code to the SoftFocus B-tree library, which was
for single user use.  Am I right in thinking that I can convert this
library to network use, by placing the appropriate record locking calls
around the physical read() and write() functions ?

If this is the case, my only other question would be the handling of a
new data record. I cannot lock the record, as it does not exist yet, but
should I lock the file, add the record, lock the record, and then unlock
the file. I know that locking beyond the length of the file (for DOS) is
ok, but will this cause any problems.

If possible please e-mail any responses, and I will post a summary to
the net later

Thanks for your help

Mike


Newsgroups: comp.lang.c
From: emakris@cs.ulowell.edu (Ernie Makris)
Subject: Linked List
Organization: /usr/u/guest/emakris/.organization
Distribution: comp
Date: Fri, 20 Nov 1992 17:06:36 GMT

Hello,
	I am recently having trouble sorting a linked list.
	The structure is:
	struct list {
		char last_name[15], first_name[15];
		struct list *next;
	};
	I want to be able to sort by last name. Demonstration code would
	be appreciated.
							Thanks
							Ernie Makris
						P.S.
						Please e-mail me @
						makrise@woods.ulowell.edu
Newsgroups: comp.lang.c
From: "Yue-Herng Lin" <yhlin@kiwi.ucs.indiana.edu>
Subject: BNF grammar for C
Organization: Indiana University, Bloomington
Date: Mon, 23 Nov 1992 22:21:32 -0500

Being to novice of this group, I just wondering: is there a BNF grammar of C
available? Or can I find some information somewhere?
Thanks for any comments in advance.
YH
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c
Subject: Re: confused
Date: 24 Nov 92 04:00:46 GMT
Organization: Comp Sci, RMIT, Melbourne, Australia

> #include <stdio.h>
> main()
> {
> float answr;
> int fact;
> int count;
> 
> printf ("This program is designed to print the factoral of a number ");
> printf ("entered by the user.\n");
> printf ("Enter your number: ____\b\b\b\b");


A style point:
    It is a good idea to make similar things look similar
    and different things look different.
Keywords like 'while', 'for', 'if' are quite different from
function identifiers.  It is a good idea to make them visually
distinct.  Two alternatives:
	f(x, y, z);			f (x, y, z);
	while (n > 0)			while(n > 0);

An implementation point:
    Check your <math.h> to see if you have a function called gamma().
Newsgroups: comp.lang.c
From: sasghm@theseus.unx.sas.com (Gary Merrill)
Subject: Re: Is this ANSI?
Originator: sasghm@theseus.unx.sas.com
Date: Mon, 23 Nov 1992 17:50:25 GMT
Organization: SAS Institute Inc.


Well, I think I've switched sides on this one -- however goofy I
think the result is in practice.

In article <1992Nov23.090611.3209@sq.sq.com>, msb@sq.sq.com (Mark Brader) writes:
|> > Now, look back at the assertion I asked you to remember.  I expect
|> > that Mark Brader is going to say `But p->data isn't an array of
|> > one element, it's an array of 101 elements.  After all, when you
|> > said malloc(sizeof(struct FM + 100), you allocated enough memory
|> > for 101 elements!'
|> 
|> No, I'm not.  That would be wrong for the reasons you said.  What I
|> did say was that while the character pointed to by the decayed
|> pointer p->data is indeed part of the one-character array p->data,
|> it is *also* part of a larger array, namely the object returned by
|> malloc(), whose size might be, say, 104 elements when considered
|> as an array of char.  Therefore the Unless clause is applicable
|> and the reference valid.

But there is no larger array.  There is a contiguous block of memory
returned by malloc(), but this is *not* an array in the technical sense
that 'array' is used in the standard.  The pointer p->data indeed
points to a position in this block of memory, and p->data is an array,
but (unforutnately?) it does *not* follow that p->data[5] is legitimate
since the only *array* in question is only 1 byte in length.

I think this exposes some sloppiness in the use of "array" at places
in the standard.  Since in fact malloc() returns a 'void *', it is
hard to construe the block allocated as an array (of what?).  You
can proceed to *look at* this block as an array.  But you *can't*
(strictly speaking) look at it as "the array p->data" because, I
would argue, 'p->data' is not a modifiable lvalue.  The p->data array
(of one element) may *overlap* a larger array, but it still doesn't
follow that you can index off the end of p->data into that larger
array *by using 'p->data'*.

This consequence may be counterintuitive initially, but it doesn't
appear to be inconsistent.


-- 
Gary H. Merrill  [Principal Systems Developer, C Compiler Development]
SAS Institute Inc. / SAS Campus Dr. / Cary, NC  27513 / (919) 677-8000
sasghm@theseus.unx.sas.com ... !mcnc!sas!sasghm
Newsgroups: comp.lang.c,comp.software-eng
From: miket@hermes.tcs.com (Michael Turner nmscore Assoc.)
Subject: Re: Will we keep ignoring this productivity issue?
Organization: Teknekron Communications Inc.
Date: Tue, 17 Nov 1992 00:33:50 GMT

In article <BxnpJL.BvM@cs.uiuc.edu> johnson@cs.uiuc.edu (Ralph Johnson) writes:
>mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
>
>>But from what I can tell, high-level hacking is
>>not something that can be put into words, never mind analyzed
>>reductionistically.
>
>[disagreement registered, much deleted here.]
>
>Studies of expert programmers have shown that knowledge is not
>organized around syntax, but in larger conceptual structures, such as
>algorithms and data structures [Adelson and Soloway].  Soloway
>claims that expert programmers organize their knowledge in plans
>that indicate the steps necessary to fulfill a particular goal
>[Soloway and Ehrlich].   In the same way, it is likely that good
>designers do not think about the notation they are using for 
>recording the design as much as they are looking for patterns that
>they can match against design plans that they have learned in the
>past.  Recognizing and teaching these design plans is therefore
>necessary to produce good designers, but we don't do it.

This description, to a great extent, covers almost any kind of
expertise.  Great chess players aren't, like chess computers, ultra-
fast lookahead machines.  Rather, they are excellent pattern-matchers
with highly trained memories.  Design notations are sort of the
chess-sets of good programmers.  "Ah, do I know how to play this
variation?  Can I turn it into such a variation?"  I don't think
that Richard Stallman slackened his pace much in moving from LISP
to C (though he might have slowed down for other reasons.)  Language
differences are, at best, the difference between using your hand
and using a joystick to control a robot hand for moving the chess
pieces.  Patience permitting, the better player will still win
the game.

This still begs the question of whether high programmer productivity is
something that can be taught.  How you get to where you get in something
like programming is very much a function of how much you love it.
As with many areas of expertise, there is no shortage of people who
are in love with the image of themselves as superior programmers.
But how many really live for the game itself?  Those, I think, are
the superprogrammers.  Can love of programming be taught?
---
Michael Turner
miket@tcs.com
From: jlothian@castle.ed.ac.uk (J Lothian)
Newsgroups: comp.lang.c
Subject: Re: graphical user interfaces
Date: 23 Nov 92 16:12:52 GMT
Organization: Edinburgh University Computing Service

In article <1992Nov23.135031.14929@cs.wayne.edu>, neelesh@happy.eng.wayne.edu (Neelesh Rangnekar) writes:
|> HI ! EVERYBODY ,
|> I am looking for a graphical user interface in C . Some routines that will help
|> me to develop either some things like pop up or pull down menus. 
|> Will some kind soul help me out.
|> Please mail me either the book name or some routines . 
|> Thanks in advance.
|> 
|> Neelesh
|>  

What sort of machine/operating system do you have in mind?
Do you have access to X-Windows on the machine you intend
to use?

James

-- 

-------------------------------------------------------
James Lothian        |      "It's life, Jim, 
james@uk.ac.ed.caad  |   but not as we know it"
From: s1110238@giaeb.cc.monash.edu.au (Lee Hollingworth)
Subject: Re: Reading Filenames into an ARRAY
Keywords: in MOSDOS, Borland C 3.1
Organization: Monash University, Melb., Australia.
Date: Fri, 20 Nov 1992 21:14:01 GMT

bobb@netcom.com (Bob Beaulieu) writes:

>I want to be able to display a list of specific files in the current
>directory from within my program. I want to be able to allow users to
>select from a list of these file to be acted upon (printed,deleted,...).

>Is there an easy way to do this? It has to be DOS 2.0+ and not a
>windows application.

Depends on the MS-DOS compiler you are using, MSC has functions such as
_dos_findfirst(fname, attrib, fileinfo) and _dos_findnext(fileinfo) to find
all matching files to the fname argument.  TC++ has similar functions as
part of their DOS libraray.

You will probably get a better responce to this article if you post it
in the comp.os.msdos.programmer newsgroup.

Lee Hollingworth
s1110238@giaeb.cc.monash.edu.au
Xref: sparky comp.lang.c:17087 comp.lang.c++:16822 comp.misc:4386
From: fhi0055@hq.dla.mil (Marc Poole)
Newsgroups: comp.lang.c,comp.lang.c++,comp.misc
Subject: #include DOS??
Date: 23 Nov 92 20:47:10 GMT
Followup-To: comp.lang.c
Organization: HQ Defense Logistics Agency/DASC, Cameron Station, VA


 I am writing this in question to an inquiry that was made to me and I
 thought was a good question, as because I didn't know myself.

 Question:  While programming in 'C/C++' you can incorporate different
 libraries, i.e. #include ???; while programming on a microcomputer, can
 one incorporate DOS commands?

 Any answers or suggestions would be greatly appreciated.

 Marc                           |     To 'C' the light
Xref: sparky comp.lang.c:17060 comp.software-eng:4475
From: behrenss@hphalle6.informatik.tu-muenchen.de (Soenke Behrens)
Subject: Re: Questions on kill signal
Organization: Technische Universitaet Muenchen, Germany
Date: Thu, 19 Nov 1992 15:56:39 GMT
X-Newsreader: TIN [version 1.1 PL7]

LIM FANG HOW (isc40038@nusunix1.nus.sg) wrote:

: How to implement a process that when receives a kill signal from the
: shell, will write some characters into a text file ? 

Forget it. You could do it with SIGINT (user hitting ^C), but a true kill
(-9, that is) cannot be acted upon. The reason for this is, I think, to
provide a surefire way of killing a program without giving the program
the chance to wreck havoc because the code that intercepts the signal
is also buggy :)

Soenke

--
===========================================================================
More than silver, more than gold, I need   !    behrenss@informatik.
electricity. I need it for my dreams.      !    tu-muenchen.de
(RACTER)                                   !  FIDO: 2:246/13 Soenke Behrens
From: 873clifton@gw.wmich.edu
Newsgroups: comp.lang.c
Subject: Re: How to use another library?
Date: 21 Nov 92 18:27:29 EST
Organization: Western Michigan University

In article <92323.155036SATCC@CUNYVM.BITNET>, <SATCC@CUNYVM.BITNET> writes:
> I am new to C and am using Turbo C++ 3.0.  Recently I got a library of
> functions (*.LIB) and have placed it in my library directory (i.e. C:\TC\LIB).
> However whenever I compile my program using these functions, I get an error
> message saying that the function couldn't be found.  Is there something I am
> doing wrong??  I would like to run the program from the IDE for easier
> debugging.  I have looked into the manual but to no avail.
> 
> Please reply me directly,
> 
> Thanks in advance,
> 
> Sameer.

You must pass the name of any non standard library to the compiler. Under Unix
versions of C the switch is `-l' I beleive. Also not under unix the convention
of calling library files as libname.a, Thus to link with the `name' library
your command line might look something like:

	> cc -o name -lname name.c

Of course your Turbo C compiler may differ, but as I remember from using
Borland once, not that differnt.

/D
--
Douglas Clifton [99clifto@lab.cc.wmich.edu]
Newsgroups: comp.lang.c
From: bandy@netnews.jhuapl.edu (Mike Bandy)
Subject: Re: external sorting
Organization: JHU/Applied Physics Laboratory
Date: Tue, 17 Nov 1992 16:54:29 GMT

In comp.lang.c you write:

>I'm writing an article on how to sort large files using Mergesort 
>and I was wondering if anyone out there know of other good
>sorting algorithms that can be used for external sorting too. 

The 'bible' of algorithms is Knuth's, "The Art Of Computer Programming".
It's now about 30 years old, but still very respected as a collection
of algorithms.  I'd check there first, then the university library.
Sorry I wasn't more help; remember "teach a man to fish ...".

>--
>Nico Tranquilli
>v. Ruffini, 13
>62012 Civitanova Marche (MC) - Italy
>phone: +39 (50) 550-266
>home phone: +39 (733) 770-332
>net: ntranqu@caticsuf.cati.csufresno.edu
-- 

	Mike Bandy
	bandy@aplcomm.jhuapl.edu
	Johns Hopkins University / Applied Physics Lab
Newsgroups: comp.lang.c
From: gumerman@aspen.ops.lmsc.lockheed.com ()
Subject: Rounding floating point numbers in C
Reply-To: gumerman@aspen.ops.lmsc.lockheed.com ()
Organization: Lockheed Missles & Space Co.
Date: Fri, 20 Nov 92 21:51:33 GMT


Hi everybody,

I have been writing come C code using VAX VMS C.  Along the way I have run
into a problem with the way the printf function rounds floating point numbers.
The way numbers are rouned is totally inconsistent.  Sometimes numbers are 
rounded up sometimes they are rounded down.  What is going on here?


Below is an example program and its output.

#include "sourcedir:include_file.c"
#include unixio
#include file
float one=0.0,two=0.0,three=0.0,four=0.0,five=0.0,six=0.0,seven=0.0,eight=0.0;
float nine=0.0;

main()
{                                              
   one = (float) 1.15;   
   two = (float) 1.25;
   three = (float) 1.35;
   four = (float) 1.45;
   five = (float) 1.55;
   six = (float) 1.65;
   seven = (float) 1.75;
   eight = (float) 1.85;
   nine = (float) 1.95;

   printf("1.15       %1.1f\n",one);
   printf("1.25       %1.1f\n",two);
   printf("1.35       %1.1f\n",three);
   printf("1.45       %1.1f\n",four);
   printf("1.55       %1.1f\n",five);
   printf("1.65       %1.1f\n",six);
   printf("1.75       %1.1f\n",seven);
   printf("1.85       %1.1f\n",eight);
   printf("1.95       %1.1f\n",nine);

 }


OUTPUT:


1.15      1.1   /* round down */
1.25      1.3   /* round up  */
1.35      1.4   /* round up  */
1.45      1.5   /* round up  */
1.55      1.5   /* round down */
1.65      1.6   /* round down */
1.75      1.8   /* round up  */
1.85      1.9   /* round up  */
1.95      2.0   /* round up  */

Does anyone know what is going on here?

Any help is appreciated,

Signed the insane programmer.

Newsgroups: comp.lang.c,comp.software-eng
From: martin@datacomm.ucc.okstate.edu (Martin McCormick)
Subject: Using erand48
Organization: Oklahoma State University, Stillwater, OK
Date: Thu, 19 Nov 1992 21:50:37 GMT


I am a novice C programmer trying to use the rand48 family of functions.
I don't know how wide-spread these functions are, but they exist on a Sun
Sparc and also on a Dec running Untrix.  What I would really like to see is
an example of code, using this function since I am having trouble deciphering
the man page to figure out exactly what I need to feed it in order to seed
the function.  The erand48 function returns a floating-point value between
0 and 1 which is exactly the type of output I want since that can be multiplied
by a constant to produce an upper limit.  
	The erand48 function requires storage for the X value, but I am
lost as to what else is needed.  Thank you for any help.

Martin McCormick WB5AGZ   Stillwater, OK
O.S.U. Computer Center Data Communications Group
Newsgroups: comp.lang.c
From: msb@sq.sq.com (Mark Brader)
Subject: Re: Is this ANSI?
Organization: SoftQuad Inc., Toronto, Canada
Date: Mon, 23 Nov 92 09:06:11 GMT

Andrew and I have been crossing postings; the one I'm responding to
now contains a wrong prediction of what I would say in my previous
posting.  I'll just address that point.

> 	Unless both the pointer operand and the result point to
> 	elements of the same array object, or the pointer
> 	operand points one past the last element of an array
> 	object and the result points to an element of the same
> 	array object, the behavior is undefined if the result
> 	is used as an operand of the unary * operator.
>
> Now, look back at the assertion I asked you to remember.  I expect
> that Mark Brader is going to say `But p->data isn't an array of
> one element, it's an array of 101 elements.  After all, when you
> said malloc(sizeof(struct FM + 100), you allocated enough memory
> for 101 elements!'

No, I'm not.  That would be wrong for the reasons you said.  What I
did say was that while the character pointed to by the decayed
pointer p->data is indeed part of the one-character array p->data,
it is *also* part of a larger array, namely the object returned by
malloc(), whose size might be, say, 104 elements when considered
as an array of char.  Therefore the Unless clause is applicable
and the reference valid.

> 		struct FM *q = (struct FM *) malloc(sizeof(struct FM) + 100);
>		... 
> 		*p = *q;

Agreed, this should not copy the 100 extra bytes.

> Another way to look at it is this.  Suppose I have a compiler that rejects:
> 
> 	void f(struct FM *p)
> 	{
> 		p->data[5] = '?';
> 	}

Then, as they say,"your compiler is broken, and you should ask for a
refund".  This is Yet Another Way in which C's very general pointer
types inhibit the compiler from doing things that you might like it to.

Of course, your system is free to abort at *run* time in f(), if it
finds that the argument passed to f() was merely a pointer to a
struct FM, and not to a larger malloc()ed area.  Saber-C, or whatever
they call it these days, would get this right.
-- 
Mark Brader, SoftQuad Inc., Toronto, utzoo!sq!msb, msb@sq.com
	A standard is established on sure bases, not capriciously but with
	the surety of something intentional and of a logic controlled by
	analysis and experiment. ... A standard is necessary for order
	in human effort.				-- Le Corbusier

This article is in the public domain.
Newsgroups: comp.lang.c
From: a7657@mindlink.bc.ca (Stephen H. Kawamoto)
Subject: CRC-32 C code needed
Organization: MIND LINK! - British Columbia, Canada
Date: Thu, 19 Nov 1992 04:40:37 GMT

I'm trying to make my CRC-32 C program work but

                  for ( c = i << 24, j = 8; j > 0; --j)
                            ========
                             this loses bits

        and when the table is built,


                        crc = (crc << 8 ) ^ crc_table[(crc >> 24) ^ *p];
                                                       =========
                                                       this loses significent
                                                       bits





                       is there a better way to do this?

--
Stephen Kawamoto <a7657@mindlink.bc.ca>
    "It is the very mind itself
     That leads the mind astray;
     Of the mind,
     Do not be mindless."
     (an old Japanese folk song)
Newsgroups: comp.lang.c