HDTenEightyP/NetNews huggingface dataset:
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c
Subject: Re: problem with foef()
Date: 17 Nov 92 08:40:30 GMT
Organization: Comp Sci, RMIT, Melbourne, Australia

In article <92316.213238U17868@uicvm.uic.edu>, U17868@uicvm.uic.edu writes:
> I am reading a binary file with fread.

Then you don't need feof().  The basic paradigm for C input is

	while (try_to_read(...) SUCCEEDS) {
	    use_the_input(...);
	}
	the loop stopped because of EOF or because of error,
	use feof() to tell which.

>   #include "header.h"

>   void dispdail(date)
>       char date[9];

WHOOPS!  This does not mean what you think it does!  A simple rule of
thumb which will help you get C functions right is
	*NEVER* use [] in the arguments of a function.
Look under "argument promotion rules" in the index of any good C text.

Use
    void dispdail(date)
        char *date;		/* or char date[]; if you _must_ */
>       {
>           int i, j, a;
>           FILE *activity_file;	/* was 'file_pointer' which is */
					/* a very unhelpful name */
>           struct activity temp;

>           activity_file = fopen("activity.dat", "rb");
            assert(activity_file != NULL);
	    /* There is no need to use fseek(), "rb" starts at the beginning */
            while (frad(&temp, sizeof temp, 1, activity_file) == 1) {
	        ... use this activity record ...
            }
            assert(feof(activity_file));
            fclose(activity_file);
>   }   /* end dispdail */
From: torek@horse.ee.lbl.gov (Chris Torek)
Newsgroups: comp.lang.c
Subject: Re: Where are literals stored?
Date: 19 Nov 1992 18:42:06 GMT
Organization: Lawrence Berkeley Laboratory, Berkeley
Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
NNTP-Posting-Host: 128.3.112.15

In article <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?

This is unspecified.  The C standard allows identical literals to live
at the same address or at differing addresses, as the implementation
pleases.

>(IBM-PC,Borland)

Please try to limit system-specific questions to system-specific
newsgroups.

>For instance, is the string a stored in the same place in the following
>two declarations?:
>
>static char a[]="ABC"
>
>funca()
>{
>char a[]="ABC";
>}

Neither of these is in fact a `string literal': in both cases the
quoted strings are initializers for objects.  String literals are
formed from quoted strings that appear in a value context, e.g.,

	char *p, *q;

	p = "ABC";
	q = "ABC";
	/* it is unspecified whether p == q */

Distinct objects, however, always compare unequal, thus the following
strictly conformant program must print `0':

	#include <stdio.h>
	#include <stdlib.h>

	char a[] = "ABC";
	int main(void) {
		char b[] = "ABC";

		printf("%d\n", a == b);
		exit(EXIT_SUCCESS);
	}
-- 
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: singg@alf.uib.no (Kurt George Gjerde)
Subject: name of file descriptor
Organization: University of Bergen, Norway
Date: Mon, 16 Nov 92 12:28:35 GMT

How can I get the filename from a filedescriptor, on Unix??

K.

Newsgroups: comp.lang.c
From: ditolla@itnsg1.cineca.it (Francesco Di Tolla)
Subject: Re: What is meant by: double A[n,m]?
Organization: Laboratorio di Fisica Computazionale, INFM. Trento Italia
Date: Wed, 18 Nov 1992 12:59:04 GMT

torstein@itekiris.kjemi.unit.no (torstein hansen) writes:

>As a newcomer to C, previously programming in Pascal, I used the
>following declaration in one of my programs:

>double A[n,m];

>I assumed (erronously) that this would give a n by m matrix. But
>obviously, it didn't.  But the compiler never gave any errors or
>warnings, and using 

>  A[rownumber,colnumber]=some_value;
> 
>was also accepted by the compiler.  I'm not asking for the correct 
>way to define an array, I found that out quickly, but what is meant 
>by A[n,m]?  It seems like the compiler just ignores the n and makes 
>it A[m].  This is also the case when assigning values to the array.

In c 'n,m' is an expression which has the value of m because expressions
separated by commas are evluated from left to right and only the last
value is kept:

exp1, exp2, ....,expN;

this evaluets to expN.
so

a=(b=5,b+1);

will assign 5 to b and 6 to the a in a way which is harder to understand than

b = 5;
a = b + 1;

>Torstein Hansen
>torstein@itekiris.kjemi.unit.no


Bye
Franz
-- 
 --------------------------------------------------------------------------
|  Francesco  D. Di Tolla            | Intern. School for Advanced Studies |
|  Dip. di Fisica Univ. di Trento    | SISSA/ISAS via Beirut, 2-4          |
|  I-38050 Povo (TN)                 | I-34013 Trieste                     |
Newsgroups: comp.lang.c
From: gregb@murphy.com (Greg Banschbach (Unigroup of New York))
Subject: Re: Memory functions  -  memcpy & memmove
Organization: Murphy & Durieu, NYC NY, USA
Date: Mon, 16 Nov 1992 15:07:53 GMT

In <BxArt0.9pE@murphy.com>, I wrote a question which got this 
 reply,  which seems to work, AND in addition tells me I need
 to look at some of the B-tree node / leaf routines to find the
 root of my problem:

	THANKS VERY MUCH FOR ALL OF THE RESPONSES......

From adam.MIT.EDU!scs Sat Nov  7 23:14:03 1992
From: scs@adam.mit.edu (Steve Summit)
To: gregb@murphy.com
Subject: Re: Memory functions  -  memcpy & memmove

In <BxArt0.9pE@murphy.com>, you wrote:

> 		Has anyone written a function which would exactly mimic
> 	memmove ?

Here's the one I use on systems without it:

	memmove(dest, src, len)
	register char *dest, *src;
	register int len;
	{
	if(src < dest)
		{
		src += len;
		dest += len;
		while(len-- > 0)
			*--dest = *--src;
		}
	else	while(len-- > 0)
			*dest++ = *src++;
	}

					Steve Summit
					scs@adam.mit.edu


Newsgroups: comp.lang.c
From: dfuller@portal.hq.videocart.com (Dave Fuller)
Subject: Re: What is meant by: double A[n,m]?
Organization: VideOcart Inc.
X-Newsreader: Tin 1.1 PL3
Date: Wed, 18 Nov 1992 13:22:51 GMT

torstein@itekiris.kjemi.unit.no (torstein hansen) writes:
:   double A[2,2];  
: gave same result as 
:   double A[2];
: 
: gave same result as
:   A[1,1] = some_value;
: and 
:   A[1] = some_value;
: 
: Can somebody enlighten me in this matter?  I couldn't find anything
: about it in any of the C books I have.  If double A[n,m] is illegal,
: shouldn't I get a warning at least?
: 
: Has it something to do with the comma operator, discarding the first
: value inside the braces?
: 

  The comma, isn't it great. what is happening is a result of the way the      
comma operator works. It doesn't discard anything, but it does actually
give a return value. The value is the operand on the right side of the
comma. A[1,2] would be same as A[2] in other words.


Dave Fuller
dfuller@portal.hq.videocart.com

Xref: sparky comp.lang.c:17072 comp.software-eng:4490
From: flint@gistdev.gist.com (Flint Pellett)
Newsgroups: comp.lang.c,comp.software-eng
Subject: Re: Will we keep ignoring this productivity issue?
Date: 23 Nov 92 19:36:11 GMT
Followup-To: comp.lang.c
Organization: Global Information Systems Technology Inc., Savoy, IL

johnson@cs.uiuc.edu (Ralph Johnson) writes:

>It is true that there are very large differences in the skills of 
>programmers.  It is also true that our theories of how to manage software
>do not take account of this, and it should.  However, there is no reason
>to believe that we cannot *someday* figure out what makes a good software
>developer and figure out how to teach it to people.  Sure, there will
>always be differences in people, but that does not mean that these
>differences are ingrained since birth.   >->Most differences are acquired,
>and that is true of most differences that make for good software
>developers.<-<  So, let's find out what these differences are and figure
>out how to teach them!

While I agree with everything else you said, I have to wonder
about this one sentence I highlighted.

Being an analytical sort, my question is, upon what data do you base
the rather sweeping conclusion you reached in the one sentence?
I would point out that there are several other alternative
conclusions about differences in productivity, not just one:

1. Most differences were ingrained physically at birth.
2. Most differences are acquired physical differences since birth.
   (i.e., bad nutrition, drug effects, etc.)
3. Most differences are physical factors which we could control,
   if we knew how.  (hormonal, affecting attention span, etc.)
4. Most differences are acquired behavior that is not related to
   software training.  (Temperment, emotional behavior, etc., much
   of this probably learned from parents.)
5. Most differences are due to differences in the work environment.
   (Better tools produce more and better results, people get more
   done in a warm office?  Maybe programmer #1 is more productive
   than #2 because he always is or is not playing music-- who knows?)
6. Most productivity differences are due to differences in training
   for programming.

You (seem to) claim #6 is true.  Especially given the large numbers of
good programmers who have come into the profession "through the back
door" from different fields (physics, engineering, english, music), I
find it hard to attribute the majority of productivity differences to
#6.  I have to believe that it is a combination of all of them, and
that NONE of them are dominant, and that more than likely my quick
list has overlooked several other important factors. 
-- 
Flint Pellett, Global Information Systems Technology, Inc.
100 Trade Centre Drive, Suite 301, Champaign, IL  61820     (217) 352-1165
uunet!gistdev!flint or flint@gistdev.gist.com
Newsgroups: comp.lang.c
From: eager@eagercon.com (Michael J. Eager)
Subject: Re: Mail Call
Reply-To: eager@eagercon.com
Organization: Eager Consulting
Date: Thu, 19 Nov 1992 17:09:27 GMT

In article 722@ualr.edu, lindstrom@acs.harding.edu () writes:
>Greetings-
>  Can someone tell me how to get a C program to make a system
>call (SunOS Unix, using the bundled compiler).  I would like
>to have a program send me a mail message every time it is
>called (it is living on another, less secure machine.. I want to
>keep track of its usage).


Try putting the following in your code:

	system("mail myself@mymachine");
or maybe
	system("mail myself@mymachine < /etc/hostname.xx0");



---
Michael J. Eager		Michael.Eager@eagercon.com
Eager Consulting		(415) 325-8077 
1960 Park Boulevard, Palo Alto, CA 94306-1141

Newsgroups: comp.lang.c
From: marcel@seas.gwu.edu (marcel)
Subject: C specification in YACC
Organization: George Washington University
Date: Thu, 19 Nov 1992 04:04:14 GMT

I am looking for the C language specification written in YACC. If you 
have it please send it to me 

		marcel@seas.gwu.edu 

I appreciate any assistance you can offer me.  Thank you 
Newsgroups: comp.lang.c
From: hasker@cs.uiuc.edu (Rob Hasker)
Subject: Re: Will we keep ignoring this productivity issue?
Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
Date: Mon, 16 Nov 1992 19:30:18 GMT

pdh@netcom.com (Phil Howard ) writes:

>mat@mole-end.matawan.nj.us writes:
>
>>Echoing my own favorite refrain: There is no circuit theory for software.
>
>The Computer Scientists are too busy trying to get people AWAY from
>thinking about the bits and bytes (and towards the abstract) to get
>people to properly understand how to deal with the bits and bytes.
>
>In EE you START from the bottom and work your way up.  You learn to
>understand the building blocks.  Computers SHOULD be taught the same
>way.  In fact I am awfully tempted to say that the circuit theory and
>digital circuits courses should be taught to even though wanting to
>become programmers.  At least some machine language should be.

The question is, what is the "bottom" in CS?  Hardware?  I suppose
that's traditional, but it's not the obviously correct answer since it
de-emphasizes looking at systems abstractly.  Besides, most schools I
know of do teach machine language (usually fairly early in the
curriculum), and most of the people here claim the current methods
aren't working very well.

Others would argue the case for the basis of CS being math.  That is,
we ought to be able to reason about our programs in roughly the same
way as mathematicians (even if we can't formally prove they're
correct).  But while math is clearly very important for developing
algorithms, and an appreciation for set theory etc. can make for better
specifications, I'm not convinced that math has a whole lot to do with
designing or coding large systems (which is where this discussion
started).  On the other hand, understanding math probably does at least
help in writing better small programs.

Rob
From: dsbb@ns1.cc.lehigh.edu (D. SPENCER BEECHER)
Newsgroups: comp.lang.c
Subject: Re: Help me track down memory leakage
Date: 17 Nov 92 17:05:30 GMT
Organization: Lehigh University

In article <BxuLIr.DK@rice.edu>, abuhr@owlnet.rice.edu (Aaron M. Buhr) writes:
>
>     I've inherited a very large C program that I am trying to maintain and
>expand, and I've come to the point where I HAVE to find out where the
>program's leaking memory.  The program starts out with about 7MB virtual
>mem usage, 6MB real, and grows over the course of 6-8 hours to around 20MB
>virtual, 10MB real.  The program uses straight malloc() and realloc() calls.
>I don't know where or how to start trying to track this down.  Any help
>would be greatly appreciated.

Try investigating "free()".  Do a (word processing) search on the string
"alloc", trace the associated variable use, and free those pointers that
become obsolete.  Do them one at a time if you're unsure about their
individual obsolescence.  A decent compiler should give you a warning if
memory for a necessary variable has been deallocated.  Make sure the
switch for checking this type of thing is on in your compiler.  I imagine
most of the memory suck can be attributed to structure or array allocation.
The first pointers I would check are those which are not used as parameters
by any function.
A word processor with a "search" function, a hard copy, and several colored
markers would probably be invaluable tools.
-- 
                   _ _     _ _     _ _
  -Spence         [O.O]   )x.x(   )O.O(
                    O       O      -*-
Organization: Applications Software, Carnegie Mellon, Pittsburgh, PA
Newsgroups: comp.lang.c
Date: Mon, 23 Nov 1992 13:50:46 -0500 
From: Richard Dale Romero <rickr+@CMU.EDU>
Subject: Re: Multiple &'s in an if statement
Distribution: comp.lang.c

Probably because you're using bit-wise and instead of logical and.
In C, a zero is false and anything else is true.  There is no specification
for what (x == y) returns other than zero or not zero.  So, suppose
that isdigit returns a 2 everytime for true, and
(iscntrl(name[(strlen(path) + 5)]))
returns a 1.  Their bitwise and is 0, ie, false.

So, to make it work, just do the following:

if(( isdigit[i] & isdigit[i+1] & isdigit[i+2] & isdigit[i+3] & isdigit[i+4])
   && (name[(strlen(path)+5)] == NULL)) {
...
}

-rick
From: throopw@sheol.UUCP (Wayne Throop)
Newsgroups: comp.lang.c
Subject: Re: question about duplicate declarations
Summary: possible use for function declarations inside function bodies
Date: 21 Nov 92 02:13:48 GMT

:: From: rene@hamel.uucp (Rene Mueller)
:: Message-ID: <2R28E4L@math.fu-berlin.de>
:: So code like
::    typ f1(paramlist) { typ f2(paramlist); ... }
:: Shouldn't be in ANY programm...

: From: torek@horse.ee.lbl.gov (Chris Torek)
: Message-ID: <27543@dog.ee.lbl.gov>
: (Stylistically, I happen to agree; function declarations with block
: scope provide nothing that the same declaration with file or global
: scope would give, except the chance to make a mistake.)

I can think of a legitimate use of the construct.  And that is to
encourage the compiler to give warnings when a function is used from 
a location that the developer did not intend.

Eg:       void portable_foo(void){
              void host_specific_foo(void);
              host_specific_foo();
          }

This records the developer's intent to use portable_foo everywhere else
in the program (even in other functions in the same file), in order
to localize the "infection" of the use of the host-specific function.
--
Wayne Throop  ...!mcnc!dg-rtp!sheol!throopw
Newsgroups: comp.lang.c
From: wells@cdsmn.mn.org (Rich Wells)
Subject: Re: Will we keep ignoring this productivity issue?
Organization: Dicomed, Inc
X-Newsreader: TIN [version 1.1 PL6]
Date: Wed, 18 Nov 1992 16:57:00 GMT

Bonus, Iniquus, Celer - Delegitus Duo (kambic@iccgcc.decnet.ab.com) wrote:
: 
: IMHO, there is probably no better background for SE than physics.  Why? 
: Problem solving.  Experimental techniques.  Basic understanding of the
: strangeness of the universe.  All useful.  

Agreed.  (Though I think that chemistry is just as good a
background (:-).)  My main beef is the almost complete
inability for "computer scientists" to set up a controlled
experiment, which is a very handy skill for debugging.

Another example: almost any article in almost any journal or
magazine concerning benchmarks.  They tend to be a lesson
in the futility of comparing apples and oranges in some
quantifiable way, with a nearly complete lack of controls.
-- 

Richard Wells  wells@cdsmn.mn.org  or  ...!tcnet!cdsmn!wells
From: nyarko@ee.ualberta.ca (David Nyarko)
Subject: Int,short int and portability of code
Organization: University Of Alberta, Edmonton Canada
Date: Mon, 16 Nov 1992 15:38:56 GMT

Hi,
If I have a program compiled by a compiler (eg TurboC) which
regards integers and short integers as 2 bytes size
and want the same program to be run on another machine (eg 
whose 'c' compiler (gcc or cc on sparcs) regards ints as 4 bytes
and short ints as 2 bytes, is there a way of overriding
the compiler defaults for these sizes in say the
Makefile instead of having to have these definitions
in all the individual 'c' files.
ie
if sparc
	int = 2 bytes
	short int = 2 byte
endif

In order not to take much bandwidth, you can
email responses to
	nyarko@bode.ee.ualberta.ca

			David
Newsgroups: comp.lang.c
From: sca@gese.ge14.mdadv.gv.at (Petzi Schweda)
Subject: Re: C coding style
Originator: sca@gese0n.ge14.mdadv.gv.at
Organization: MD-ADV, Vienna, Austria
Distribution: NA
Date: Mon, 23 Nov 1992 08:28:16 GMT


In article <1992Nov20.213253.386@cs.mcgill.ca>, iceman@honey.cs.mcgill.ca writes:
|> Hello,
|> 
|> 	What kind of convention is usually used for naming global variables?
|> 	I know Apple recommends adding a lower-case 'g' in front of the
|> 	variable name, e.g. gDeviceList. However, when using multi-file
|> 	projects, this doesn't differentiate between static globals (private
|> 	to the module) and extern globals (public globabls that can be
|> 	refered to from outside the module they're declared in).
|> 
|> --

I would strongly recommend to avoid global variables at all !!!
Extern (non-static) globals give you lot's of problems when you organize your code (maybe later ?) in shareable images (I've ran into this under VMS and with Windows-DLL's).
Static (module-wide) globals must be handled VERY carefully to keep your code reentrant (sp?) and reusable. 
Nearly any static I've used (expect from the typical "is_initialized") to store control-data did kick me in the ass in the worst moment it could ...

be aware, petzi

Petzi Schweda (sca@gese.ge14.mdadv.gv.at)
MD-ADV, Municipality of the City of Vienna, Austria
  
Xref: sparky comp.lang.c:16584 comp.software-eng:4309
From: jschell@sdcc13.ucsd.edu (As if I'd tell you!)
Newsgroups: comp.lang.c,comp.software-eng
Subject: Re: Will we keep ignoring this productivity issue?
Summary: Comp. Sci. engineering course
Date: 16 Nov 92 11:02:04 GMT
Followup-To: comp.lang.c,comp.software-eng
Organization: University of California, San Diego

In article <1992Nov16.091643.13590@netcom.com> pdh@netcom.com (Phil Howard ) writes:
>The Computer Scientists are too busy trying to get people AWAY from
>thinking about the bits and bytes (and towards the abstract) to get
>people to properly understand how to deal with the bits and bytes.
>
>In EE you START from the bottom and work your way up.  You learn to
>understand the building blocks.  Computers SHOULD be taught the same
>way.  In fact I am awfully tempted to say that the circuit theory and
>digital circuits courses should be taught to even though wanting to
>become programmers.  At least some machine language should be.
>
>
>/***********************************************************************\
>| Phil Howard  ---  KA9WGN  ---  pdh@netcom.com   |   "The problem with |
>| depending on government is that you cannot depend on it" - Tony Brown |
>\***********************************************************************/

Well, I have no idea where you went to school or how long ago, but
I'm currently enrolled in the EE program at UC San Diego and I will
be switching to CS soon.  Again, I can't speak for other schools,
but here at least, the EE and CS programs are pretty close to each
other in some of the upper-division classes and identical in the
lower-division.  The lower-division classes include Assembly
Language on a 68030 chip along with introduction to basic hardware
concepts and implementations such as logic gates, etc.  Also, both
programs include a sequence of three actual EE classes and three
concurrent EE labs to go with them.  So you see, there are computer
scientists being taught the building blocks.


+----------------------+------------------------------------------+
|  --> Jon Schell <--  |  "Andre, you mean to tell me that you    |
|      The Master      |  have lost _another_ sub?"               |
|      tm@ucsd.edu     |             -- The Hunt for Red October  |
|   jonschell@aol.com  |  "REboot to the head."  --me             |
+----------------------+-------------------------------------+----+
| No one else would be crazy enough to claim these opinions. | 42 |
+------------------------------------------------------------+----+
Newsgroups: comp.lang.c