HDTenEightyP/NetNews huggingface dataset:
From: torek@horse.ee.lbl.gov (Chris Torek)
Newsgroups: comp.lang.c
Subject: Re: How does the Address-of Operator (&) really work?
Date: 12 Nov 1992 13:31:42 GMT
Organization: Lawrence Berkeley Laboratory, Berkeley
Distribution: world
Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
NNTP-Posting-Host: 128.3.112.15

In article <1ds9htINNd81@agate.berkeley.edu> achoi@soda.berkeley.edu
(Andrew Choi) writes:
>  I was told that the address-of operator & (along with sizeof)
>is done at compilation [time]

This is not strictly correct.  Many systems will compute addresses
during compilation, rather than at runtime, but there is no such
guarantee in the language.  Furthermore, addresses of automatic
objects do not even exist at compile time:

	void pointless(void) {
		int i, *j = &i;
		...
	}

The value `&i' is not a compile-time constant.

>therefore, it becomes legal to do the followings:
>
>  &(((struct S *) NULL)->field)

This also is false.  It usually works, and is how many (if not most)
implementations actually implement the ANSI `offsetof' macro, but it is
not guaranteed to work, or to return anything useful.  (This is *why*
ANSI *has* an offsetof macro.)

>However, what I don't understand is how it works under multiple
>files.  Considered the followings:
>
>  /* file "foo.c" */
>  char *a = "This is a test";
>
>  /* file "bar.c" */
>  char **b = &a;
>
>When the 2 files, "bar.c" and "foo.c" are separately compiled,
>what does the compiler put for "&a", since it does not know where
>the definition for "a" is?

The compiler must emit some sort of directive to the rest of the
compilation system---which may be called the `linker' on your machine
---telling it that it has to initialize `b' before calling main().
This initialization is typically performed at link time, although
again there is no such guarantee in the C language.

Remember that the ANSI standard says only that there is a *system* that
acts as specified by the standard.  It does not say how the system is
built, or how it is to do what it must.  It says only *what happens*.

The actual mechanics on traditional systems, at least for this case,
are that the `object files' are in a special format (e.g., a bit
stream, a sequence of records, a set of sections, or whatever) that
includes a `symbol table' and `relocation information'.  The relocation
information says things like:

	In file bar.o, at offset +104 in the read/write data section,
	insert the value of the global symbol `_a'.

The actual encoding varies wildly from one system to another.  Any
system that implements the ANSI C standard must provide *some*
mechanism by which a static pointer variable can be set to point to a
named static object plus an integer constant offset, or to a named
function (without an offset), but the standard (and this newsgroup)
will not say how *your* system does this.  Your system's particular
needs are unique to your system, and you should find them described
in documents (and newsgroups) also specific to your system.
-- 
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: jmwojtal@vela.acs.oakland.edu (Wojo)
Subject: Someone help me with this
Organization: Oakland University, Rochester MI.
Date: Fri, 6 Nov 1992 21:05:07 GMT

I'm trying to do this program that goes into a void subroutine,

void getday(char *, int, char *);
...
char fname[10];
int day;
char timetab[33][31];

getday(fname, day, timetab);
...
void getday(char file[], int dy, char holdday[][]);
{
...
}

Now it keeps giving me errors about different syntaxes.  

Using C for the PC, what is the corrent way to apply this so it will work?
The subroutine is supposed to get values for timetab only;

Thanks for the help



-- 
************************************************************************
Jeff Wojtalewicz (Wojo)  jmwojtal@vela.acs.oakland.edu
Oakland University		      Start Hacking
************************************************************************
Newsgroups: comp.lang.c
From: goudreau@batman.rtp.dg.com (Bob Goudreau)
Subject: Re: The Correct Way To Write C if-Statements
Date: Thu, 12 Nov 92 21:27:28 GMT
Organization: Data General Corporation, RTP, NC

In article <hansg.721510062@risken> hansg@risken.vd.volvo.se (Hans Granqvist) writes:
>goudreau@robin.rtp.dg.com (Bob Goudreau) writes:
>
>->	if ( OpenCode ) ...
>
>-Is anyone else as repelled as I am by the practice of leaving the
>-parentheses surrounded by whitespace on both sides?  Not only does
>-it violate such de-facto standards as K&R or H&S, it goes against
>-common English usage as well ( and if you don't believe that, then
>-tell me what's wrong with this parenthetical question? ) .
>
>Hmm... in my opinion, every person putting two (2) spaces at the end of
>a sentence ('full stop'?) not only breaks a de facto Swedish standard but also
>shows great unsolidity in his language. 

"Unsolidity in his language"?  Whatever does that mean?

Anway, if I were posting in Swedish, then perhaps I'd put only one
space after each period.  But in English, two following spaces *IS*
the standard (look it up).   And (getting back to the point), I'll
bet that even in Swedish you don't insert gratuitous spaces between
parentheses and the clause which they surround.


>-Moving on to another topic...
>
>->	if ( SomeDarnThing == TRUE ) ...
>
>-If "SomeDarnThing" (amazing how the whitespace fanatic seems to hate
>-underscores!) is a boolean variable, then what is the point of testing
>-it against TRUE or FALSE?  The following is more concise and easier
>-to read:
>
>-	if (some_darn_thing) ...
>
>
>Aye, relating to your latest remark on coherence with common language
>usage, is your proposed fashion more correct than the other? 

I don't understand this comment.  The presence or absence of the
"== TRUE" code has no connection with punctuation conventions at all.
The thing which I find objectionable is the silly testing against
TRUE or FALSE.  Certainly the practice of using

	if (condition)

instead of

	if (condition == 1)  /*  or == TRUE */

is well established in C; look at K&R1.  So why add needless
verbiage?


>And, then, is there the slight casuality that 'TRUE' was defined to, per
>chance, '4711'?

In which case there is the large *certainty* that the coder is an
idiot!  Anyone who defines TRUE and FALSE such that (! TRUE) isn't
equal to FALSE or (! FALSE) isn't equal to TRUE shouldn't be coding
in C.  The only pair of values that meet both conditions is 0 for
FALSE and 1 for TRUE.

----------------------------------------------------------------------
Bob Goudreau			Data General Corporation
goudreau@dg-rtp.dg.com		62 Alexander Drive	
+1 919 248 6231			Research Triangle Park, NC  27709, USA
Newsgroups: comp.lang.c
From: eager@eagercon.com (Michael J. Eager)
Subject: Re: largest structure size on pc (in c)
Reply-To: eager@eagercon.com
Organization: Eager Consulting
Date: Thu, 12 Nov 1992 08:24:31 GMT

In article 235722U17868@uicvm.uic.edu, <U17868@uicvm.uic.edu> () writes:
>my  program is listed below. it is very short. All I am trying to do is to
>read from a file. But, I think the problem is that the structure size is too bi
>g. It compiles successfully.I am using Turbo C 2.0. When I run it I get the mes
>sage "Null Pointer Assignment". I tried different ways that is using malloc, wi
>thout malloc, defining structure as a tag and then declaring an instance, but n
>othing helpded. I have 2M RAM on my pc.Anyone has any suggestion send it to
>u17868@uicvm..cc.uic.edu
>
>Thanks,
>Sikander
>===================my program ============================================
>#include <stdio.h>
>#include <stdlib.h>
>struct {
>	int  id;
>	char  date[9];
>	char day[10];
>	int  stime;
>	int  length;
>	char location[10];
>	char with_who[10];
>	char phone[11];
>	char subj[10];
>	char note[10];
>        int  flag;
>}temp;
>
>main()
>{
>int i;
>FILE *file_pointer;
> file_pointer = fopen("activity.dat","rb+");
> fseek(file_pointer,0,0);
>
> for(i=0;i<=4;i++)
>     {
>       scanf("%d",&temp.id);
>       gets(temp.date);
>       gets(temp.day);
>       scanf("%d",&temp.stime);
>       scanf("%d",&temp.length);
>       gets(temp.location);
>       gets(temp.with_who);
>       gets(temp.phone);
>       gets(temp.subj);
>       gets(temp.note);
>       scanf("%d",&temp.flag);
>       fwrite(&temp,sizeof(temp),1,file_pointer);
>       }
> }
>


Your program looks OK, but you don't tell what you have as input.

Null pointer assignment means that somewhere you have a pointer with
the value 0 which is dereferenced and a value stored.  It has nothing
to do with the size of the structure (which is just fine) or with the
amount of memory on your computer.

If you happen to read in more than 9 characters into temp.note, it will
overwrite whatever follows (same is true for the other char arrays).  In
this case, you stand a good chance of stepping on other data.

Does the file "activity.dat" exist?  If it does not, it will not be 
created, and file_pointer will be NULL.  You do not check for this.

---
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: giglio@betsy.gsfc.nasa.gov (Louis Giglio)
Subject: EBCDIC to ASCII Conversion Revisited
Keywords: EBCDIC, ASCII
Reply-To: giglio@betsy.gsfc.nasa.gov (Louis Giglio)
Organization: NASA/GSFC
Date: Thu, 5 Nov 1992 22:00:37 GMT


As Gary Merrill pointed out (article 16895), my original question didn't
make sense.  I'll try and explain my question more clearly:

I have a binary file written on an IBM mainframe.  The file
contains mostly numeric data, but embedded in it are many EBCDIC strings.
I transfer the file with ftp (binary mode) to a UNIX machine.  (Can't use
ftp text mode otherwise numeric values will be scrambled.)

Once on the UNIX machine I use a C program to read the numeric data just fine
(I can take care of the byte swapping if it's needed).  However, I need a way
to convert the embedded EBCDIC strings into ASCII.  Currently I have a klunky
256-byte lookup table made with the UNIX dd command (with conv=ascii switch),
but I was wondering if there is a more intelligent way to do this.  Thanks.


Louis Giglio
Severe Storms Branch
NASA/GSFC

Newsgroups: comp.lang.c
From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
Subject: Re: Fortran to C conversion: Why bother?
Organization: Texas Instruments Inc
Date: Wed, 11 Nov 1992 22:37:35 GMT

In <1992Nov11.185431.13154@hubcap.clemson.edu> mjs@hubcap.clemson.edu (M. J. Saltzman) writes:

>In article <1992Nov11.172747.1959@mksol.dseg.ti.com> mccall@mksol.dseg.ti.com (fred j mccall 575-3539) writes:
>>In <20849@fritz.filenet.com> scotth@felix.filenet.com (Scott Hopson) writes:
>>
>>>In article <1992Nov9.131601.167@gems.vcu.edu> hleaves@gems.vcu.edu writes:
>>>>I was wondering why anyone would bother using the f2c (or similar) program to
>>>>translate fortran code directly into C. 
>>>>[...]

>>>[...]
>>>Many companies think seriously about converting their old code into new code,
>>>even if the functionality is the same. This is because they usually want the
>>>same functionality but with the opportunity to enhance old systems.
>>
>>The problem with this decision is that the code resulting from
>>automatic translations is usually something less than maintainable, so
>>you would still have to either maintain the FORTRAN or reimplement in
>>maintainable C.  

>That's right, but maintaining the Fortran isn't such a bad way to go.
>One of the points in this thread is that "f2c | cc" is a perfectly
>servicable Fortran compiler substitute for many applications.

Perhaps not, but you've added another possible source for errors to
your build stream.  Anyway, the rationale offered was that all the
FORTAN gurus were gone.  WHO is going to maintian the FORTRAN if all
the folks who were good at FORTRAN have departed?

>>Converters are useful for those cases where you need
>>to get the first release of a product out the door when you are in a
>>new environment, but IMHO trying to maintain the output of a converter
>>after chucking the original code is rather like maintaining object
>>after chucking the source code.  It is somewhat more difficult than taking
>>the time to reimplement properly in the new language.

>I don't think it's widely a widely-advocated strategy to maintain the
>*output* of any program generator.  You always maintain the input.
>It's more or less like compiling your C code, throwing away the source
>and trying to maintain the code using the assembler listing.

Yes, but once again, the post being responded to gave as the reason
for using the conversion tool the premise that all the FORTRAN gurus
had left.

-- 
"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.
From: sasghm@theseus.unx.sas.com (Gary Merrill)
Newsgroups: comp.lang.c,comp.lang.c++,comp.lang.pascal,comp.lang.misc
Subject: Re: Godel's Proof (was Re: Software design =/= Programming)
Date: 10 Nov 92 15:37:11 GMT
Article-I.D.: unx.BxIBDz.481
Organization: SAS Institute Inc.
Originator: sasghm@theseus.unx.sas.com


In article <BxHz2v.EK4@sci.kun.nl>, hansm@cs.kun.nl (Hans Mulder) writes:
|> In <LOEGEL.92Nov9134531@fegatello.ssc.gov> loegel@fegatello.ssc.gov (George J. Loegel) writes:
|> >From the McGraw-Hill Dictionary of Science and Technology:
|> >Godel's Proof: Any formal arithmetical system is incomplete in the
|> >sense that, given any consistent set of arithmetical axioms, there are
|> >true statements in the resulting arithmetical system that cannot be
|> >derived from these axioms.
|> >--- end of def ---
|> 
|> This is inaccurate.  Counterexample:
|> 
|> Axioms: all closed first-order arithmetical formulae that are true when
|> 		interpreted w.r.t. the natural numbers.
|> Rules of inference: none needed.
|> 
|> This formal system is consistent, since there no formulae F s.t. both F
|> and ~F are true.  It is complete, since there are no _closed_ formulae F
|> s.t. neither F nor ~F is true.
|> 
|> It doesn't fall for G\:odel's Theorem because it is not semi-decidable,
|> i.e. for a given formula F one cannot (in general) decide whether it is
|> an axiom in this system.
|> 
|> --
|> Hope this helps,
|> 
|> Hans Mulder				hansm@cs.kun.nl

I don't think it will help this thread.  But you should be commended
for the effort.  Here is an algorithm whose application *will* help:

	1. Acquire a copy of _Computability and Logic_ by Boolos
	   and Jeffrey.

	2. Read it.

	3. Do the proofs (i.e., expand the proof sketches into
	   full proofs).

If you apply this algorithm to its completion you will understand
the relations of completeness, decidability, finite axiomatizability,
truth (in models and the standard model), and related concepts.
It's a lot of fun too.  (Don't cheat now!  Do all the steps.)

-- 
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
From: mgream@acacia (Matthew Gream)
Newsgroups: comp.lang.c
Subject: statistical functions in C wanted
Date: 7 Nov 92 03:45:28 GMT
Organization: University of Technology, Sydney
NNTP-Posting-Host: acacia.ccsd.uts.edu.au
X-Newsreader: Tin 1.1 PL5


 Im looking for statistical functions in C, such as student-t 
confidence level tables (or routines to generate the appropriate
t values), also chi-squared routines/tables.
 Can anyone point me in the right direction ? I need them in
relation to a subject im taking (Engineering Statistics).

Thankyou,
Matthew.

--
M.Gream@uts.EDU.AU - Matthew Gream - 'Edges have holes next to them .. '
Newsgroups: comp.lang.c
From: tlhouse@nyx.cs.du.edu (fiver)
Subject: Re: Bad Joke
X-Disclaimer: Nyx is a public access Unix system run by the University
	of Denver for the Denver community.  The University has neither
	control over nor responsibility for the opinions of users.
Organization: Nyx, Public Access Unix at U. of Denver Math/CS dept.
Date: Fri, 6 Nov 92 23:33:09 GMT


>I heard a "joke" from my boss today...goes something like this,
 
 
>With all of of President-elect Clinton's promises made, he'll have to
>be extra careful of decisions and carefully scrutinize his 
>actions..i.e.
 
>                C-lint-on   
 
 
>Get it........
 
>But seriously folks.....
 
horrid .. absolutely evil .. I like ..
From: throopw@sheol.UUCP (Wayne Throop)
Newsgroups: comp.lang.c
Subject: Re: pointer explanation
Date: 05 Nov 92 01:29:33 GMT

: From: jcl@bdrc.bd.com (John C. Lusth)
: Message-ID: <895@bdrc.bdrc.bd.com>
:         " if((strcmp (*records[min].last, *records[j].last)) > 0) "
:     Given
:         struct entry **records;
:     then
:         *records[i].last
:     is wrong because * binds tighter than [],

If the problem were a confusion between precedence of * and [], there
wouldn't be a type mismatch, but a run-time subscripting error.  We
know that *x is equivalent to x[0], so the error you think you saw is
just the difference between saying x[0][N] and x[N][0], both of which
necessarily have the same type decomposition.

: Would anyone care
: to try a more succinct and clear headed explanation I can pass along
: to my student?

Actually [] binds tighter than *, so this properly indexes the list,
landing on a pointer.  The problem is that . ALSO binds closer than *,
so the attempt is made to find a field of a non-struct (a pointer, that
is).  That's why you have to say

                  (*foo).bar 
instead of
                  *foo.bar

The best idea is probably to rewrite the original "if" line as

        if((strcmp (records[min]->last, records[j]->last)) > 0)

As an afterthought, the error message you quoted wasn't too
informative.  On a DECstation, gcc says

    request for member `f' in something not a structure or union

lint says

    struct/union or struct/union pointer required

the bundled K&R-plus-ANSI-extensions C compiler says

    ccom: struct/union or struct/union pointer required
          f(){ return *spp[23].f; }
          ---------------------^
    ccom: illegal indirection
          f(){ return *spp[23].f; }
          ----------------------^

the unbundled ANSI C compiler says

    "spp[23]" has a pointer type, but occurs in a
                  context that requires a union or struct.

The clearest message is the one from the K&R-plus-ANSI-extensions
compiler, because it makes it clear that the "." is being parsed
before the "*".  All of these make it clear that there is a type
problem with the "." operation.
--
Wayne Throop  ...!mcnc!dg-rtp!sheol!throopw
Newsgroups: comp.lang.c
From: champion@cch.coventry.ac.uk (Alun)
Subject: Re: Printing out trees
Organization: Coventry University, Coventry, UK.
Date: Mon, 9 Nov 1992 10:56:21 GMT

In article <gezTJc_00VQsAo9Vpl@andrew.cmu.edu> rickr+@CMU.EDU (Richard Dale Romero) writes:
~Does anyone have code for printing out arbitrary binary trees,
~ie, not necessarily full, can have 0, 1 or 2 children?
~
~Any sort of method or strategy would be nice, doesn't even
~really have to be code.  I'm just stumped for a nice, efficient
~way to do it--everything I've tried has been ugly.


print(Tree* tree)             
{
    if(tree == 0)
        return;
    print(tree->left);
    printf("%d\n", tree->val);
    print(tree->right);
}

Does this look okay ??
By realigning the print and printf() statements you could print the
tree in any order. :-}
Depends on how your tree is sorted (if indeed it is sorted at all).

    -Alun

-- 
A.Champion                |  That's an interesting point, in the sense of
(champion@uk.ac.cov.cck)  |    being very not interesting at all. - The Liar
Newsgroups: comp.lang.c
From: dfuller@portal.hq.videocart.com (Dave Fuller)
Subject: Re: Need help reading floats from file
Organization: VideOcart Inc.
X-Newsreader: Tin 1.1 PL3
Date: Sat, 7 Nov 1992 06:02:23 GMT

dfuller@portal.hq.videocart.com (Dave Fuller) writes:
: 
: /* note that each of the first elements has associated with it the 
: /* 20 numbers that were on the line in the file
: /*
: /*  i.e.  numbers[1][5] = 6th number in the first line
: /*                        yes 6th, 0 indexing here . . . 
: 
 woops !!  that should read as the 6th element in the 2nd line, Sorry
 numbers[0][5] would be the 6th element in the 1st line

Dave Fuller
dfuller@portal.hq.videocart.com
From: torek@horse.ee.lbl.gov (Chris Torek)
Newsgroups: comp.lang.c
Subject: Re: LHS Casting
Date: 13 Nov 1992 19:16:03 GMT
Organization: Lawrence Berkeley Laboratory, Berkeley
Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
NNTP-Posting-Host: 128.3.112.15

In article <1992Nov13.050054.28251@druid.uucp> darcy@druid.uucp
(D'Arcy J.M. Cain) writes:
>Is it safe to say that there is never any case where a cast belongs on
>the LHS of an assignment?

It depends on what you mean by this.  For instance,

	*(int *)p = v;

could well be OK, and it has a `cast ... on the LHS'.  The thing is
that this cast is embedded within a larger expression.

The result of a cast is a value, not an object.  Only objects can have
their values replaced (or, for op= operators, modified).  Hence,

	/* given any declaration for p, and `int i;' */
	(int *)p = &i;

is just plain illegal.  Any ANSI-conformant compiler must emit `at
least one diagnostic' for code containing such an assignment.

Some compilers violate the ANSI standard, accidentally or deliberately,
and sometimes allow these assignments---with compiler- and/or machine-
specific results.
-- 
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: jeff@titan.ucc.umass.edu (DarkShadow)
Subject: Re: HELP ON C BOOK
Organization: University of Massachusetts, Amherst
Date: Sat, 7 Nov 1992 03:53:21 GMT

In article <1992Nov7.020947.6467@usl.edu> cs460129@ucs.usl.edu (Martinez Velez Jose Carlos) writes:
>I'm trying to learn c and I wonder if anyone out there knows a good to 
>learn c. I already know pascal and modula-2, so if anyone knows of a book
>relating any of this language to c, please sent me e-mail...
>
>
>       E-mail: cs460129@ucs.usl.edu
>                      or
>                  fjl0014@usl.edu
>
>
I would be interested in this info as well.  If anyone would like to
include my name on their mailing list, that would be great.  Thanks a
lot.

  -Jeff

-- 
Jeff Zabek				email:  jeff@titan.ucc.umass.edu
Computer Science Department			gencon07@titan.ucc.umass.edu
University of Massachusetts
Newsgroups: comp.lang.c
From: dherity@cs.tcd.ie (Herity D.)
Subject: Re: cvs
Organization: Computer Science, Trinity College Dublin
Date: Wed, 11 Nov 1992 12:15:21 GMT

hamjavar@hydra.unm.edu (Farid Hamjavar) writes:


>Hello : 

>Has any one heard of this softeware called CVS  -- for managing
>project source codes.  Do you know if it can be obtained free from
>some archive (ftp).

I'd like to know where to get it also.

-- 
================================================================================
| Dominic Herity,  dherity@.cs.tcd.ie,                      | Something clever |
| Computer Science Dept, Trinity College, Dublin 2, Ireland.| coming soon to a |
| Tel : +353-1-6772941 ext 1720 Fax : +353-1-6772204        |signature near you|
Newsgroups: comp.lang.c