HDTenEightyP/NetNews huggingface dataset:
From: mjn@pseudo.uucp (Murray Nesbitt)
Subject: Re: dynam mem alloc
Organization: Private system in Toronto, ON
Date: Sun, 30 Aug 1992 10:33:11 GMT


barmar@think.com (Barry Margolin) writes:

>In article <MJN.92Aug26015009@pseudo.uucp> mjn@pseudo.uucp (Murray Nesbitt) writes:
>>ecm@casbah.acns.nwu.edu (Edward Malthouse) writes:
>>>int *x;
>>>if(n == NULL) /* memory has not been allocated */
>
>Where did "n" come from?
>
>>>This works fine as long as the pointer variable was declared as global or in
>>>main().  If it is declared elsewhere this statement does not work.  For
>>>example:
>
>>Yes, there is a portable way.  Use the storage-class specifier
>>``static''.
>
>That's not a good answer, since it has more effects than just solving this
>problem.  Besides being initialized to 0 automatically, static variables
>also retain their value across calls.  So if he frees the object before
>returning from the function, the next time he comes in he'll think that the
>memory has already been allocated (or worse, since doing anything with a
>pointer to freed storage is a no-no).

You're telling me this like I don't already know what ``static'' does.

The way I understood his article was that he was looking for a way to
ensure a pointer variable with block scope would 1) be initialized to
NULL, and 2) retain its value between invocations of the block, so
that he would be able to malloc() some memory only in the first
invocation of the block, and on subsequent invocations be able to
reliably test whether memory had already been allocated to the
pointer.

>
>He should just provide an explicit initializer:
>
>int *x = NULL;
>

No, he shouldn't, because each time the block is executed, x will be
set to NULL.  If all he was looking for was a way to initialize a
pointer to NULL when entering a block of code, do you *really* think
he wouldn't have thought of this method?

>BTW, the fact that it is automatically initialized in main() is just a
>feature of that particular implementation.  There is no required default
>initialization of automatic or register variables, so you should always
>provide an initializer if you care.

I think it's more likely that the variable in question just happened
to have the initial value 0, as opposed to being explicitly
initialized by the implementation.

-- 
Murray
Newsgroups: comp.lang.c
From: tomg@code3 (Tom Green)
Subject: curses mouse
Organization: 3M Health Information Systems
Date: Thu, 27 Aug 1992 20:25:56 GMT

I have noticed in the curses header files for a couple of *nix's that there
is support for mouse control.  I, however, can't find documentation on how
to use the functions to set up and make use of my rodent.  Any one have a
reference to documentation, or at least some pointers to me on how to start
using this I would appreciate.  Please e-mail and If I get requests I will
summarize.


-- 
Tom Green
- Life's a pain, then you die.                            _/_ __ ____ __
  "I shall be merciful and quick" - the Gorn              /  /_// / //_/
tomg@code3.code3.com                                                 _/
From: torek@horse.ee.lbl.gov (Chris Torek)
Newsgroups: comp.lang.c
Subject: string literal concatenation (was printf question)
Date: 3 Sep 1992 16:01:27 GMT
Organization: Lawrence Berkeley Laboratory, Berkeley
Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
NNTP-Posting-Host: 128.3.112.15

In article <1SEP199221241770@eql.caltech.edu> rankin@eql.caltech.edu
(Pat Rankin) writes:
>>Minor quibble:  string concatentation is performed by the compiler,
>>not the preprocessor. ...

In article <MJN.92Sep3000652@pseudo.uucp> mjn@pseudo.uucp
(Murray Nesbitt) contends:
>Concatenation of character string literals is performed during the
>preprocessing phase of translation.

Both are technically wrong; someone else (I forget who) got it right.
Just for the record, the ANSI C standard (X3.159-1989) does not divide
the task of compilation into `preprocessing' and `compilation' phases
as such.  Rather, it lists *eight* separate phases.  Phase 4 might be
called the `preprocessing' phase, but the standard does not do so.
Syntactic and semantic analysis, which might be called `compilation',
is phase 7.  String literal concatenation occurs in phase 6.

Loosely speaking, then, concatenation occurs *between* preprocessing
and compilation, not during either one.

We now return you to your regular programming: megabytes of Unix- and
MSDOS-specific news inappropriately directed to a generic C group. :-)
-- 
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: jle9162@venus.tamu.edu (ECKHARDT, JASON LEE)
Subject: MIX simulator
News-Software: VAX/VMS VNEWS 1.41    
Organization: Texas A&M University, Academic Computing Services
Distribution: usa
Date: Mon, 24 Aug 1992 04:24:00 GMT

  Looking for a MIX simulator/interpreter for Knuth's MIX assembly language.
'C' source code is preferable, but anything is fine.

I posted this here because I don't think there is a .knuth group and some of
you 'guru/wizards' surely know Knuth and MIX and where to find those type
of things.

Thanks, Jason. email reply would be nice... jle9162@venus.tamu.edu

Xref: sparky comp.lang.c:13075 comp.std.c:2546
From: karl@ima.isc.com (Karl Heuer)
Newsgroups: comp.lang.c,comp.std.c
Subject: Re: scrcpy implementation question
Date: 1 Sep 92 19:39:36 GMT
Organization: Interactive Systems, Cambridge, MA 02138-5302

In article <PINKAS.92Aug21114508@caraway.intel.com>, pinkas@caraway.intel.com (Israel Pinkas) writes:
> A compiler group working for us has told us that they plan to make the
> following optimization for the strcpy library function:
> [Unrolled loop of word moves, copying past the terminator, up to the smaller
> of compile-time dst_size and src_size]

Presumably it is important to get the wrong answer as fast as possible.

Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint
Newsgroups: comp.lang.c
From: u-dmfloy%jensen.cs.utah.edu@cs.utah.edu (Daniel Floyd)
Subject: Re: Most difficult part of learning C?
Date: 27 Aug 92 08:59:08 MDT
Organization: University of Utah CS Dept

In article <17g9mlINNsu1@early-bird.think.com> barmar@think.com (Barry Margolin) writes:
>In article <chuckb.714781695@milton> chuckb@milton.u.washington.edu (Chuck Bass) writes:
>>I would bet that assembly language programmers have no problem
>>picking up C's notion of pointers.
>
>I disagree.  Assembly programmers are used to pointers being addresses, and
>arithmetic on pointers being address arithmetic.  They're probably the ones
>who get most confused by C's automatic scaling during ptr+integer
>calculations, and don't understand why p+=sizeof(*p) doesn't do what they
>expect.
>Barry Margolin
>barmar@think.com          {uunet,harvard}!think!barmar

I have to agree and disagree here.  I learned assembly language before C
which gave me a good grasp on the concept or "notion" of pointers.
This helped; unfortuneately, I still fell prey to C's automatic scaling
with pointer arithmetic as Barry suspected.

Dan Floyd
From: hawkeye@glia.biostr.washington.edu (Ken Keys - TF Dude)
Newsgroups: comp.lang.c
Subject: Re: How to handle __STDC__
Keywords: ANSI C, prototypes
Date: 30 Aug 92 09:07:57 GMT
Article-I.D.: glia.hawkeye.715165677
Organization: University of Washington

In <393@bsovax.UUCP> albert@bsovax.UUCP (Albert van der Horst) writes:

>C) concerning __STDC__
>This built in #define is used most often to govern the use of
>prototypes.

>K&C II says about __STDC__ :
>" __STDC__ may only be one if the C-system is ANSI standard"
>or some such.

>This would imply that you can have "#define __STDC__ 2"
>on a non standard system. Mark Williams is doing something
>substantially more reasonable : "#define __STDC__ 0" to convey that
>its c-compiler is not standard.

>The result is that I cannot compile programs that use
>"#ifdef __STDC__". However this seems common practice in sources
>distributed via the net, but I have seen "#if __STDC__" as well.

>Can someone with access to (and understanding of!) the official
>standard please give an authoritive answer to this?

The ANSI/ISO standard does say that __STDC__ must be defined as 1 in
any standard-conforming compiler.  However, since a non-standard
compiler is, by definition, not bound by the standard, it can do
whatever it wants, including defining __STDC__ as 1.  I agree, however,
defining __STDC__ as 0 was a bad choice on the part of Mark Willams,
since a lot of existing code does use the "#ifdef __STDC__" check.  My
only suggestion is to use "#if __STDC__" in your own code, and hope
no vendor is stupid enough to #define __STDC__ 1 in a non-standard
compiler.

-- 
--
Ken Keys, aka Hawkeye
Master of the Fugue
kkeys@ucsd.edu or hawkeye@ucsd.edu
Newsgroups: comp.lang.c
From: dhesi@cirrus.com (Rahul Dhesi)
Subject: Re: How to handle __STDC__
Organization: Cirrus Logic Inc.
Date: Mon, 31 Aug 1992 19:55:04 GMT

I believe the problem is that a non-boolean situation (i.e., how
standard-conformant a compiler is) is being indicated using a boolean
condition.  The result is like digitized sound on a home computer that
drives the speaker with a flip-flop.

===== begin saved article =====
Newsgroups: comp.lang.c
From: dhesi@cirrus.com (Rahul Dhesi)
Subject: Re: The __STDC__ That Wouldn't Die!
Message-Id: <1991Nov27.201130.14777@cirrus.com>
Date: Wed, 27 Nov 1991 20:11:30 GMT

In <gwharvey.691197381@node_25b73> gwharvey@lescsse.jsc.nasa.gov (Greg
Harvey) writes:

>A particularly GOOD example of this is the C compiler for Apollo.
>It is not anywhere CLOSE to fully ANSI compliant, but they have
>defined the __STDC__ macro.  It MYSTIFIES me why someone would
>do this!

Being a heretic, I think that *all* C compilers should predefine
__STDC__.  Reasoning:

1.   Many careless programmers do stuff like

     #ifdef __STDC__
     ... some feature that works for ANSI C ...
     #endif

thus making the assumption, often incorrect, that just because __STDC__
is not defined, the feature they want is not available.  The fallacious
reasoning they are using is:

     (A => B) => (not A => not B)


Such programmers need to be persuaded not to trigger code on __STDC__.
If all compilers defined __STDC__, these programmers would learn
quickly.

A real example:  A true standard C environment is not permitted to
predefine the fileno() macro in <stdio.h>, but reasonably portable code
can still need it.  To compile such code, the user may be obliged to
turn off the standard C environment, thus undefining __STDC__, and
losing the many features that would be available if the code could see
__STDC__ defined.

2.   Just because __STDC__ is defined is no reason to assume that the
compiler adheres to the letter of the standard.  We already know that
AT&T deliberately defines __STDC__ to be 0 or 1 according as the
compiler is or is not believed to adhere to the standard.  Other
compilers (e.g. gcc) may define __STDC__ if the compiler "sort of"
adheres to the standard and some other symbol (e..g __STRICT_ANSI__) to
show attempted full adherence.  Still others (e.g. most C compilers for
MS-DOS) define __STDC__ even though there may be instances in certain
"memory models", in which the compiler does not adhere to the
standard.

Since the real world is the way it is, and __STDC__ means little or
nothing, it would be a good thing if we made it mean "nothing" rather
than "little", so that we wouldn't need to guess which "little" it
means.

4.   A non-ANSI C compiler can define anything it wants to without
changing its standard-conformance status.
-- 
Rahul Dhesi <dhesi@cirrus.COM>
UUCP:  oliveb!cirrusl!dhesi
"You're even nuttier than we've come to expect of you." -- Doug Gwyn
===== end saved article =====
-- 
Rahul Dhesi <dhesi@cirrus.com>
also: dhesi@rahul.net
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: main()
Date: 2 Sep 92 15:03:25 GMT
Organization: AND Software BV Rotterdam

In article <cee1.715416182@Isis.MsState.Edu> cee1@ra.msstate.edu (Charles Evans) writes:
|Ok, I thought supposadly in ANSI C/C++ one was to declare main() as such:
|either:
|
|int main(void) or void main(void)
|
|BC++ books say int main(void) but what is the benefit of 'return 0' at the
|end.. seems like wasted space.
|Now in VERY new C++ books or VERY new C books, they usually have either
|
|int main() or void main()
|
|so what is wrong with 'main()' .. ANSI i suppose
|so what should i use: void main(void) looks best (to me)?
|any htoughts?

Well, the standard says:

2.1.2.2.3 Program termination

A return from the initial call to the main function is equivalent to
calling the exit function with the value returned by the main function
as its argument. If the main function executes a return that specifies
no value, the termination status returned to the host environment is
undefined.

[ end quote ]

This suggests to always include a return statement or an exit() function
call. The standard defines the definitions in paragraph 2.1.2.2.1 as:

int main(void /* or argc and argv here */) { /* ... */ }

I can imagine implementations where int functions are called in a 
different way then void functions would be called. On such (weird?)
implementations, the startup code (which assumes main to be a function
returning an integer value) would fail to call your (void) main 
function correctly. Better stay on the safe side and define it the
way they want you to define it. And it doesn't waste much space
to include a `return 0' statement just before termination. It'll
keep all the scripts happy that use your program and depend on
its exit status value ...

kind regards,

Jos aka jos@and.nl
From: jfoy@glia.biostr.washington.edu (Jeff Foy)
Newsgroups: comp.lang.c
Subject: Some help requested
Date: 23 Aug 92 19:12:59 GMT
Article-I.D.: glia.jfoy.714597179
Organization: University of Washington



Hello, I need some assistance.

I have a file (which we'll call foo.txt) that has, among various
other information, a line which reads:

  ddddd,cccccccc

However sometimes the line can read:

  d , cccccccc

or even:

  dd ,cccccccc

where        d = an ascii digit between "0" and "9"
      cccccccc = can be from 1 to 8 characters

The problem  is that  the first  part (before  the comma)  is not
always formatted the same way. The second part (after the  comma)
is always between 1 and 8 characters.

My question is -- how can I move just "cccccccc" into a character
array? I don't need the first part or  the comma  delimiter, only
the second part.

Tried using strchr() but always get the comma (which I don't need
or want). Am very confused.

Any thoughts, comments, or code would be very welcome.
-- 
Jeffery Foy -- Either: jfoy@glia.biostr.washington.edu -or-
                       foysys!jeffery@cs.washington.edu
             *** FREE BILL & KATHY SWAN ***
-*- Happy as a clam to be using Professional YAM -*-  :)
Newsgroups: comp.lang.c
From: svenning@cc.curtin.edu.au
Subject: Importing custom Turbo routines?
Organization: Curtin University of Technology
Date: Wed, 26 Aug 1992 06:30:47 GMT

I recently obtained a set of Turbo C library routines that perform some
simple functions such as pull down menus, text window setup etc... but since
I haven't really had mucxh experience using library modules (since I have always
written everything myself!) I have absolutley no idea how to access, let alone,
include these routines in my program.
  Does anyone know how to access the routines and pass parameters to them.
I will go into more detail via e-mail if you need further information.
There was some documentation included but it only listed the internal params.
I think and the header declarations, not how to pass in or what comes out.
  Does the library tcu32 ring a bell? Well, that's it but I don't know how
to use it. I've written to the author but am still waiting for a reply. Any help
will be gratefully appreciated!

                                                                Regards,
                                          				Todd.

Newsgroups: comp.lang.c,comp.sys.sun.misc
From: news@epas.toronto.edu (USENET)
Subject: Re: sun cc optimization failure
Organization: University of Toronto
Date: Thu, 3 Sep 1992 22:38:57 GMT

>          If you're entertaining wild guesses, mine is that the
>          compiler picked up that since ax is zero, j will always be
>          zero.
>
>          Try initializing ax to a non-zero number.

This should not make a difference.  The compiler should still realize
that the function call to puts is something to do, and hence
evaluation of j to zero should not effect the outcome.

Other compilers I have used did the same incorrect thing.  To get
around this, just call a function to consume the value that is being
lost.  This way the compiler will think the value is needed and not
optimize it away.

Tom
From: pape@plato.chemietechnik.uni-dortmund.de (David Pape)
Newsgroups: comp.lang.c
Subject: multiple dirs in a makefile
Keywords: make,makefile
Date: 3 Sep 92 13:20:58 GMT


	Heres my (highly simplified) project directory setup:

proto:	makefile, resultant executable

proto/x:	x.c, x.h, x.o
proto/y:	y.c, y.h, y.o

How can I run "make" in the "proto" dir, and have it put "x.o" and
"y.o" in the correct directories? I also want to be able to run
"makedepend" from the makefile in "proto" so that it creates the 
dependencies correctly, i.e:

# DO NOT DELETE THIS LINE -- make depend depends on it.

proto/x/x.o: proto/x/x.h
proto/y/y.o: proto/y/y.h

Even when I have
---------------------------------
X_PATH = proto/x

depend:
	makedepend $(X_PATH)/x.c
---------------------------------
in my makefile, I always get

x.o: proto/x/x.h	#notice missing path

Any helpful hints out there??

--
David Pape				 | "Justice is inci- | 	       ///
pape@plato.Chemietechnik.Uni-Dortmund.DE |  dental to law    | 	\\\ UNI_DO
Dortmund, Germany			 |  and order"       | 	 \\\///
tel: 49 231 7552682			 | - J. Edgar Hoover | 	  \\//
Newsgroups: comp.lang.c
From: ih96@sol.acs.unt.edu (Yu Zhi)
Subject: why execve() call wouldn't return to the calling program?
Keywords: execve, unix, process
Organization: University of North Texas
Date: Thu, 27 Aug 1992 22:10:57 GMT

Hi there. I got a question. I'm working under unix and have some fortran
program which I would like to call over and over again. So I decided to
write a c program and use execve() calls. But one thing made me mad is that
after the call of execl(), the control won't retrun to the c calling program.
I'm sure there some way to around this. Hope someone can give me a hint.
Please mail me your suggestion since I don't read news very often. Thanx. 
Newsgroups: comp.lang.c,comp.lang.pascal
From: IQTI400@INDYCMS.IUPUI.EDU (macphil)
Subject: Re: Pascall Typed Files
Organization: IUPUI
Date: Tue, 1 Sep 1992 18:12:34 GMT

In article <10270@vice.ICO.TEK.COM>
bobb@vice.ICO.TEK.COM (Robert Beauchaine) writes:
 
>  As another poster has mentioned, TP strings are different than C
>  strings in that the dynamic length of the string is placed at byte
>  0, rather than having a null termination.  You should read the 26
>  bytes into memory and then massage the Pascal string into C format.
>
 
TPW is nice in that it now supports the <PChar> datatype to be compatible
/c C strings (hence access to OWL).
Newsgroups: comp.lang.c
Subject: Re: Most difficult part of learning C?
From: selig@sysjj.mdcbbs.com
Date: 31 Aug 92 11:56:00 GMT
Organization: McDonnell Douglas M&E, Cypress CA
Nntp-Posting-User: selig

In article <15230@ksr.com>, jfw@ksr.com (John F. Woods) writes:
> goldstei@cgi.com ("Morris Goldstein") writes:
>>I am conducting research for a little project concerning difficulties in
>>learning C and how to improve the teaching of C so as to circumvent these
>>problems.
>>When learning C, what things did you find the most confussing/difficult to
>>understand?
> 
          Pointer to pointers has always bothered me.

          Dan
From: pjunold@daimi.aau.dk (Peter Joachim Unold)
Newsgroups: comp.lang.c
Subject: strstr and ANSI-c
Summary: how ANSI-c is strstr
Keywords: strstr ANSI
Date: 29 Aug 92 21:55:50 GMT
Organization: DAIMI: Computer Science Department, Aarhus University, Denmark

Hello

I've for some time been coding on a program, that must be compiled and run
on many diff. unix platforms. Apart from the usual portability problems one 
encounter in unix-programming, I have had problems with users reporting, that
their ANSI-c compiler reports the 'strstr' string-function unknown. How is 
that? strstr IS according to my K&C 2. edition part of the standard-library.
I could ofcause just code my own strstr function, but if one can't expect the
ANSI-c-compilers to fullfill the ANSI-standard, what can one expect?

 thanx

   peter unold
      pjunold@daimi.aau.dk
From: linley@seas.ucla.edu (Bruce Linley)
Newsgroups: comp.lang.c
Subject: Order of execution...
Keywords: Umm, Uhh, Well, Daa, Gee
Date: 29 Aug 92 04:17:22 GMT
Distribution: usa
Organization: SEASnet, University of California, Los Angeles

This subroutine is supposed to convert a string to all lower case:

int StripCase(textLine)
char textLine[];
{
  register int index = 0;
  
  while ((textline[index++] = tolower(textLine[index])) != '\0');
}

The question is will it always work? Or will sometimes work depending on which
side of the assignment gets evaluated first (up to the compiler)? Is there a
better way to do this (and still keep it a one liner). Thnaks in advance.

--
Bruce Linley         | Evil code:
linley@seas.ucla.edu | #define BEGIN {
Comp Sci & Engr      | #define END }
Organization: Arizona State University
Date: Thursday, 27 Aug 1992 10:55:15 MST
From: Vegesna Srinivas Raju <ASRIN@ASUACAD.BITNET>
Newsgroups: comp.lang.c
Subject: FAQ - Request

Hello

Can someone please post or mail me a copy of the FAQ for this group.

Thanx

Vegesna Srinivas Raju
Newsgroups: comp.lang.c
From: atbowler@thinkage.on.ca (Alan Bowler)
Subject: Re: How to fprintf two column
Organization: /etc/organization
Date: Sat, 29 Aug 1992 01:11:59 GMT

In article <5663.87.uupcb@wugate.wustl.edu> jon.ault%travel@wugate.wustl.edu (Jon Ault)  writes:
>VA. 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. (?)
>
>I would approach this by writing the first column out to a temp file, 
>then reading it back in and appending the second column, writing that 
>out to the final output file.  

Right solution.  You might hunt arround for an existing utility to
to this column concatenation.  Its trivial in some editors, and often
statistical packages have some side tools that do exactly this with
files.  It is not hard to "rool your own" but why bother if the utility
is already on the system.
Newsgroups: comp.lang.c