HDTenEightyP/NetNews huggingface dataset:
From: hamish@sybase.com (Just Another Deckchair on the Titanic)
Newsgroups: comp.lang.c
Subject: Re: Pointer/address reluctance
Date: 25 Aug 92 16:44:35 GMT
Distribution: na
Organization: Sybase Inc, Emeryville CA USA

In article <10444.610.uupcb@spacebbs.com> ted.jensen@spacebbs.com (Ted Jensen) writes:
	[...]
<IMHO, I find it much easier to think of an address as a value
>which identifies a location in memory, and a pointer as a
<variable designed to hold a value which identifies a location in
>memory, i.e. an address.
<
>Based on the above definitions (which I feel few could argue
<with), a pointer is an lvalue whereas an address is not.  Thus,
>there is a distinct difference between the two.  What is
<frustrating is when a writer states that a function or
>calculation "returns a pointer".
<
>The problem, of course, stems from the failure to distinguish
<between an integer variable, and an integer value, a float
>variable and a float value, etc.  Consider the following:

	[rest of posting deleted]

Erm, I'm sure I've missed *something* here, but if you want to use your
own integer value / integer variable analogy, surely you want to use:

	pointer value / pointer variable

in this context?

In that case, of course, the word "address" disappears (as does most of
the rest of your article and the analysis therein)....


	Hamish
---------------------------------------------------------------------------
Hamish Reid       Sybase Inc, 6475 Christie Ave, Emeryville CA 94608 USA
+1 510 596-3917   hamish@netcom.com  hamish@sybase.com  uunet!sybase!hamish
Newsgroups: comp.lang.c,comp.lang.c++
From: zeranguek@gtephx.UUCP (Karl Zerangue)
Subject: Tool for measuring size (no. of statements) of C/C++ programs
Keywords: metrics, size, complexity, comparing versions
Organization: gte
Date: Mon, 31 Aug 1992 23:09:30 GMT

We are in the market for a tool which produces the size (in numbers of
statements) of C/C++ programs.  Ideally, we would like such a tool to
tell us how a new version of a module changed as compared to some previous 
version, i.e., where did differences in the numbers of statements occur.
This would be somewhat like the UNIX 'diff' command, except that this tool
must be sensitive to what a *statement* is.

Even names of companies (other than ABRAXAS, please!!) that *might* offer
such a thing would be helpful.

Thanks in advance!
From: pwestlak@eoe.co.uk (Peter Westlake)
Newsgroups: comp.lang.c
Subject: Re: How to fprintf two columns?
Date: 27 Aug 92 17:47:57 GMT
Organization: EO Europe Limited, Cambridge, UK
X-Newsreader: Tin 1.1 PL3

KSZ@VM.NRC.CA writes:
: I need the following output to a file:
:                     1.2     2.3
:                     1.3     2.4
:                     1.4     2.5
:                       ....
: which contains two columns. They are not generated at the same time, i.e.
: at the first the first column is generated and then write to a file. then
: the file is rewinded and the second column is generated. Now I need write
: the second column to that particular place, say begin with 10th column.
: I have tried fseek() but it  seems to me not working. (?)
:  
The way to do this is to think of the file as a stream of bytes:

	sp sp 1 . 2 sp sp  2 . 3\n sp sp  1 . 3 sp sp 2 . 4 \n ......

Leave a gap after each number in the first column, wide enough for
the second column entry. For instance:

	printf("%5.1f  .....\n", first);

Then fseek to each gap (bytes 7, 19, 32... in this example layout) and
write the second column:

	printf("%5.1f", second);

For the numbers of the second column you have to fseek between each one.
For the first you can just write enough extra characters to take you to
the right place, which is what all the dots are doing in the first printf.

Here is a complete example, which I have just run (as befits one who
tests software for a living! :-)

#include <stdio.h>

main()
{
	long i;
	float f;

	f = 1.2;
	for (i = 0; i < 3; i++) {
		printf("%5.1f  .....\n", f);
		f += 0.1;
	}
	f = 2.3;
	for (i = 0; i < 3; i++) {
		fseek(stdout, 13*i+7, 0);
		printf("%5.1f\n", f);
		f += 0.1;
	}
	exit(0);
}
------------------------------------------------------------------------------ 
Peter M Westlake                        EO Computer Ltd.,
Tel: +223-843131                        Abberley House,  Granhams Road,
Fax: +223-843032                        Great Shelford,
email:  pwestlak@eoe.co.uk              Cambridge CB2 5LQ,   England
From: hennebry@plains.NoDak.edu (Michael J. Hennebry)
Newsgroups: comp.lang.c
Subject: Re: Politically Correct C (was: Re: Freedom of Speech (was: Mister Ed Nilges)
Date: 30 Aug 92 18:35:56 GMT
Distribution: usa
Organization: North Dakota Higher Education Computing Network

In article <1992Aug28.150040.21463@Princeton.EDU> egnilges@phoenix.Princeton.EDU (Ed Nilges) writes:
>but it is inexcusable to code

>     if (!(farkle))

>since it is obvious even to the tyro that the "scope" of the not
>operator ! is "farkle" (what else COULD it be??)  

Without the "extra" parentheses it could be "fire" as in the following
example:

boss.h: /* immutable if peon wants to keep his job */

#define farkle fire || flood

peon.c:

    if( !farkle ) {
       fprintf(stderr, "Surprise.  ( !farkle ) =/= ( !(farkle) )\n");
    }
-- 
Mike   hennebry@plains.NoDak.edu
"I still thing it's garbage, but beautifully cooked."   --  TP on TP
From: dik@cwi.nl (Dik T. Winter)
Newsgroups: comp.lang.c
Subject: Re: c<->fortran
Date: 30 Aug 92 12:22:38 GMT
Organization: CWI, Amsterdam

In article <1992Aug30.112532.11192@cs.hw.ac.uk> suthan@cs.hw.ac.uk (Manickam Umasuthan) writes:
 > Dear Netters,
 > I tried the following piece of code which interfaces with a fortran routine
 > which in turn uses the EXTERNAL statement and the external function is defined
 > in C. But in my machine the output is wrong. I like to know where the error
 > is.
Try the following change:
 > 	subroutine  start(fname,x)
 > 	EXTERNAL fname
 > 	real x
add:	double precision fname
 > 	print*, fname(x)
change this to:
	print *, fname(dble(x))
 > 	END
-- 
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland
home: bovenover 215, 1025 jn  amsterdam, nederland
dik@cwi.nl
Newsgroups: comp.lang.c
From: curt@watson.ibm.com (Curt McDowell)
Subject: Re: strcpy implementation question
Date: Thu, 27 Aug 1992 15:34:41 GMT
Disclaimer: This posting represents the poster's views, not necessarily those of IBM
Organization: IBM T.J. Watson Research Center

In article <9224017.23144@mulga.cs.mu.OZ.AU>, fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
> >In article <PINKAS.92Aug25163006@caraway.intel.com>, pinkas@caraway.intel.com (Israel Pinkas) writes:
> >> The fact that the memory has not been initialized is irrelevant.  If the
> >> source didn't care about it, neither will the destination..
> >

> >This is wrong.  It isn' the source or the destination that cares, it is
> >strcpy() that cares.  strcpy() MUST NOT READ any uninitialised memory
> >locations.

Well, I wouldn't state it that way.  I'd say it must not read anything
outside of its own stack, global variables in the C library, or other memory
it legally allocates.

> I'm sorry, but this is wrong.
> The code to implement strcpy() does NOT have to be ansi-conformant - hell,
> it doesn't even have to be written in C! It IS allowed to read
> uninitialised memory locations, so long as that doesn't stop it doing its
> job correctly.
> 
> The following function correctly implements strcpy on my machine:
> 
> 	#define MINDLESS_USE_OF_UNITIALIZED_MEMORY 
> 
> 	char *strcpy(char *dest, const char *src) {
> 	    char *retval = dest;
> 
> 	#ifdef MINDLESS_USE_OF_UNINITIALIZED_MEMORY
> 	    char unused[4];
> 	    unused[0] = (unused[1] *= (unused[2] += unused[3]));
> 	#endif
> 
> 	    while (*dest++ = *src++) ;
> 	    return retval;
> 	}
> 
> It might not work on *your* machine, but that's irrelevant.

It better work on your machine.  "unused" is legally allocated local stack
space, so of course you can reference it.  Since the initial contents are
undefined, the result unused[0] is undefined.  Fine.

> If the compiler can determine that there referencing memory past
> the end of the string will not cause any side-effects, then it is perfectly
> entitled to do so.

No compiler can determine this for the general strcpy().

A good, portable strcpy MAY NOT access extra bytes before or after the
source string, just the exact bytes of the string.  That's because the
memory outside the string may be illegal address space, particularly
where virtual memory or hardware parity checking is concerned, and you'd
trap trying to read it.

You laugh.  Then, you write an optimized assembly memcpy() for a real
C library.  Then.... you stop laughing  :-|

> Fergus Henderson             fjh@munta.cs.mu.OZ.AU      

--
Curt McDowell
IBM T. J. Watson Research Center
Newsgroups: comp.lang.c,comp.sys.sun.misc
From: dwb@IMD.Sterling.COM (David Boyd)
Subject: Re: sun cc optimization failure
Reply-To: dwb@IMD.Sterling.COM
Organization: Sterling Software
Date: Thu, 3 Sep 1992 14:21:12 GMT
X-Md4-Signature: 3e1b90b1ac2c2c80844f6ac1e227dbf5

In article <1992Sep3.040401.16902@mr.med.ge.com>, carl@aslmr-serv.med.ge.com
(Carl Crawford) writes:
|> 
|> consider the following program:
|> 
|> main() {
|> 	int i,j,ax;
|> 	ax = 0;
|> 	for(i=0;i<3;i++){
|> 		j = ax * i;
|> 		puts("in for loop");
|> 	}
|> }
|> when compiled with cc (sun os 4.1 on sparc 1+), the 
|> code runs thru the loop three times. when comiled with 
|> the -O flag it only runs once. hom come the optimization 
|> screws up the loop?
|> --
	This is the second post of this problem I have seen.  I have also
personally run into it (at 2:00am debugging a rather complex terrain masking
program).  The problem is specifically with the multiply of the loop varient
inside the loop.  The problem is not just limited to the for construcnt
I have seen it occure on while loop as well.  My best suggestion is to code
around the problem (I know its not as easy as it sounds).  Is anyone from
Sun out there listening?  Does Sun even care given that they are unbundling
the compiler?  The problem does not exist in GCC at least.

-- 
David W. Boyd	             UUCP:     uunet!sparky!dwb
Sterling Software IMD        INTERNET: dwb@IMD.Sterling.COM
1404 Ft. Crook Rd. South     Phone:    (402) 291-8300 
Bellevue, NE. 68005-2969     FAX:      (402) 291-4362
Newsgroups: comp.lang.c
From: drm4005@wuee1.wustl.edu (David Russell Maffitt)
Subject: MS-C fread bug
Organization: Washington University, St. Louis Mo.
Date: Thu, 3 Sep 1992 14:11:00 GMT

Here is a simple piece of code that does not work under MS-C versions 6.0 or
7.0.  WHY?  Just save the file as main.c and compile with "cl main.c".

What is magic about the value 70.689651???  This works fine if I change
the value slightly (70.689600 works but 70.689650 does not).  Is this a
horrible bug or do I have more brain damage than I realize??
I'd appreciate a sanity check.  I'd like to hear how this runs on similar
and different hardware with the Microsoft compiler.  

The read hits end of file on an HP Vectra 386/25 with DOS 5.0, MS-C v7.0,
10M RAM, 386MAX extended memory management, and no coprocessor.  
It also fails on an HP Vectra ES/12 with 
DOS 3.3 and MS-C v6.0 with 640K RAM and a coprocessor.

----- start file main.c --------------------------------------------------
#include <stdio.h>

#define MAGIC   70.689651

main()
{
	FILE	*fp1, *fp2;
	float	fval1 = MAGIC, fval2;

	if( (fp1 = fopen("bin.val","w")) == NULL) {
		printf("Error opening file bin.val for writing.\n");
		exit(-1);
	}

	if( fwrite((char *)&fval1,sizeof(fval1),1,fp1) != 1) {
		printf("Error writing file bin.val.\n");
		exit(-1);
	}
	fclose(fp1);

	if( (fp2 = fopen("bin.val","r")) == NULL) {
		printf("Error opening file bin.val for reading.\n");
		exit(-1);
	}

	clearerr(fp2);
	if( fread((char *)&fval2,sizeof(fval2),1,fp2) != 1) {
		if( ferror(fp2) != 0) {
			printf("Error reading file bin.val.\n");
			exit(-1);
		}
		if( feof(fp2) ) {
			printf("End-of-File reading file bin.val.\n");
			exit(-1);
		}
	}
	printf("fval2 = %f",fval2);
	exit(0);
}
---- end main.c --------------------------------------------------------
Newsgroups: comp.lang.c
From: tony@nexus.yorku.ca (Anthony Wallis)
Subject: Why should POINTERS be so damn hard to understand ?
Organization: York University
Date: Wed, 26 Aug 1992 18:30:54 GMT

Jim Sullivan (sullivan@alw.nih.gov), in response to  
> > When learning C, what things did you find the most
> > confusing/difficult to understand?
says
> What else?... POINTERS!

(This seems to be a common gripe from students subjected to that
 Blaise-ing insult known as "Pascal" too.)

Having cut my own computing teeth on the old-school machine model of
immediate operands, direct and indirect addressing and address
calculation, the higher-level-language abstraction of "pointers" always
seemed to me to be pretty obvious, and the fussing about pointers a
make-work project for the terminally syntactically-fixated.

How can you understand C without understand what C is a convenience
replacement for ?

But then, I've always understood generalised abstractions *initially*
in terms of underlying less-abstract mechanisms.
E.g.
   power              initially in terms of   parents and teachers
   money              initially in terms of   coins and candy
   sex                initially in terms of   domestic pet reproduction
   recursion          initially in terms of   stacks
   X toolkit+widgets  initially in terms of   Xlib
   Xlib               initially in terms of   X Protocol
   X Protocol         initially in terms of   bytes up and down that cable

Seems to me like there's too much about the teaching of pointers in C,
Pascal, etc. that resembles, say, the teaching of gerunds and
gerundives by professional Latin teachers, or, say, the teaching of
differential calculus by professional mathematicians.

Understand the MACHINE MODEL and you will understand POINTERS.

--
tony@nexus.yorku.ca = Tony Wallis, York University, Toronto, Canada
Newsgroups: comp.lang.c
Subject: Re: How can I multiply and divide 32-bit fixed-point numbers?
From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
Date: 2 Sep 92 15:42:14 GMT

In <17vhblINNi9d@agate.berkeley.edu> benrg@ocf.berkeley.edu (Ben Rudiak-Gould) writes:

>I'm using ints as fixed-point numbers with 16 bits of integer and 16
>bits of fraction.  What's the best way to multiply and divide two of
>these and return a third? 

If you have a 64-bit data type (let's call it Long, for the moment), then
you can use:

((Long) a) * ((Long) b) >> 16

and

((Long) a) << 16) / b

Otherwise, you pretty much have to use standard multiprecision methods:

#define Hi(x) ((x) >> 16)
#define Lo(x) ((x) & 0xffff)

a * Hi(b) + Hi(a) * Lo(b) + Hi(((unsigned) Lo(a)) * ((unsigned) Lo(b)))

and whatever Knuth suggests for a 3-word by 2-word multiple precision
division, assuming a 16-bit "word".

(I probably could reconstruct it, as I've written some mp routines here,
but Knuth should be easier to understand.)

--
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; if you want to be sure I see a post, mail it.
From: cteague@ra.cs.umb.edu (Charles F. Teague II)
Newsgroups: comp.lang.c
Subject: How to link in .BGI files? (TC++ v1.0)
Date: 2 Sep 92 16:18:47 GMT
Organization: University of Massachusetts at Boston


  OK, I give up.  I've written a small program that uses TC's graphics
functions.  It compiles and runs fine -- so long as the EGVVGA.BGI file
is in the current directory.  I don't want to copy this file everywhere on
my hard disk, so I tried to link it in.  A file called BGIOBJ.EXE looked
promising, so I ran it w/o args for a help message.  I got one, sort of.
It's no help to me, though.  I've ransacked all four manuals I got with
TC++ v1.0 (Getting Started,User's Guide,Prog. Guide, + Lib. Ref.), and all
I've found said that I have to have the bgi files in the current directory.

  All I want is to somehow link in the .BGI file in with my program, so I
can put it in my path and run it from anywhere.  If anyone can give me
some detailed help on what opts I need for tcc, or what other utilities
I need to use (bgiobj.exe?), I would be grateful.

--
Charles F. Teague II  Net:cteague@cs.umb.edu  Real:33 Sidney Ave, Lynn MA 01902
+------------------------------------+-----------------------+----------------+
| Computers are so powerful because  | "Don't do what I SAY, | 'lush' CS 1993 |
| they do whatever you tell them to. |  do what I mean!!!!"  | TKE-zm sn 603  |
+------------------------------------+-----------------------+----------------+
Hi!  I'm a replicating .sig virus!  Join in the fun and copy me into yours!
From: rot@multisys.com (Republic of Taiwan)
Newsgroups: comp.lang.c
Subject: Re: fscanf problem...
Date: 3 Sep 92 07:27:39 GMT
Organization: Multimedia Information Systems Corporation, San Jose, CA                        TEL: (408) 437-3031            E-mail: info@multisys.com

In article <chans.714976579@lillee> chans@lillee.cs.curtin.edu.au (Sean Chan) writes:
=Gidday all,
=
=I am trying to read a file containing a 2x2 dim array of integers. The
=numbers are indented in the file...
=
=eg.
=     2   2   2   1   20   30   40   70... and so on...
=
=I'm trying to get fscanf to read each integer at a time but I get a core
=dump. It's used like this :-
=
=      fscanf (infile, "%d", val);

If you declare 'int *val;' then you should have no problem.
Apparently, you declare 'int val;'.

Then you write you code this way,

      fscanf (infile, "%d", &val);

Any C books should have cover this. Next time try to
solve the problems by reading books first.

=
=Any reason why I'm getting a core dump?? Doesn't fscanf automatically
=skip the spaces and read the integers only??
=
=Sean
=***********************************************************************
=*			                 *                            *
=* Sean Chan		                 *   Inside every microchip   *
=* Student Number : 892561F	         *   there is a little man    *
=* 3rd Yr. Computer Science	         *   running around doing     *
=* Curtin University of Technology        *   everything you have      *
=*                                        *   asked him to do...       *
=* E-Mail : chans@marsh.cs.curtin.edu.au	 *                            *
=*          pchans@cc.curtin.edu.au	 ******************************
=*				         *
=******************************************
Newsgroups: comp.lang.c
From: hsm@kepler.unh.edu (Crazy Irma, She's Gonna Go Nuts!)
Subject: gcc v. cc 
Keywords: HALP!
Organization: The Shrine of the Sacred Bleeding Head of Jane (I didn't MEAN to make _Barbarella_) Fonda Bar and Grill
Date: Tue, 1 Sep 1992 02:17:05 GMT

OK!
I've been developing a program under gcc, the FSF C compiler.
now, I need it to run under cc (the ULTRIX RISC C compiler) on a
DS5100

I finally got the code to compile, but it gives totally outlandish
numbers, hundreds of orders of magnitude off from what they should be.

I'm using gets, fgets, fscanfs and sscanfs to input my data, the
calculations I'm doing are just translations, rotations and shears,
nothing too mindwarping..

I know this is insufferably vague...but is there some magic thing that
might be broke?  ANY help will be appreciated.

Or would some kind soul be willing to look at circa two hundred lines
of code?

reply via email plz.

					h.



Newsgroups: comp.lang.c
From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
Subject: Re: Giles' Manual Mania (Was
Organization: Texas Instruments Inc
Date: Tue, 25 Aug 1992 15:31:06 GMT

In <395.174.uupcb@ssr.com> dick.zeitlin%acc1bbs@ssr.com (Dick Zeitlin)  writes:

>FJM5> .>Third, as badly as the documents are written, it's more cost effective
>    > .>to have *one* person read them and have everyone else ask!

>FJM5> .No it isn't, and for a lot of reasons.  I'm sorry, but this assertion
>    > .is just plain silly.  That's like saying that it makes more sense on a
>    > .team of programmers to have one person know the language and all the
>    > .rest just ask him how to implement things.

>IMHO, you're both wrong, and you're both right.  It's silly to expect
>everyone to start off with the full knowledge set required for any
>possible job.  It's equally silly to expect all information to come from
>a single person acting as the "fount of all arcane knowledge."

>The idea is to be available, and to provide appropriate levels of
>information.  There's nothing wrong with a structure where one can ask
>for help, as long as an appropriate level of response is provided.  If
>I'm asked how to frabulate widgets, I might reply to check out the
>munge(0) call and the format of the wonky.foo data structures.

>What's wrong with that?  You've provided useful information, and at the
>same time, you've shown the questioner a line of thought, and a pointer
>to appropriate documentation.

Nothing is wrong with that.  It is, in fact, exactly what I said to do
(rather than simply giving them the answer, as Jim says to do).  I
think that even appears in your other note (where you seem to be
chastising me for doing what you say you would do).


-- 
"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
Subject: Making Headers
From: robertson@physc1.byu.edu
Date: 30 Aug 92 16:37:20 -0600
Distribution: world
Organization: Brigham Young University

 Hi,

  Using Gnu C, how can one make their own headers.  I have a group of
  subroutines I would like to use in more than one program, can I use
  an Include <header.h> with those subroutines in the file header.h
  Or must I preprocess, preprocess and compile, or preprocess, compile
  and assemble? the header.h file first before doing a complete
  compile to my program with the include statement.

  Thanks for the help,

      Jim Robertson       robertson@physc1.byu.edu
Newsgroups: comp.lang.c
From: kui@mff.uniba.cs (Katedra u.inteligencie)
Subject: kui@mff.uniba.cs
Organization: Faculty of Maths & Physics, Comenius University, Bratislava, Czechoslovakia
X-Newsreader: Tin 1.1 PL4
Date: Thu, 3 Sep 1992 09:00:54 GMT


Newsgroups: comp.lang.c