HDTenEightyP/NetNews huggingface dataset:
From: scjones@thor.sdrc.com (Larry Jones)
Newsgroups: comp.lang.c
Subject: Re: Sun Spots recently sighted on Earth (was: Re: Simple C question)
Date: 29 Aug 92 22:21:12 GMT

In article <tim.714749643@mal-s1>, tim@mal-s1.gatech.edu (Tim Shelling) writes:
> Our system administrator installed Sun's "acc" last Fall on our SPARCstations.
> The man pages lists acc as the ANSI C compiler. This *is* a Sun OS product.
> An ANSI lint and yacc also are in neighboring directories and are mentioned
> in the acc man pages.

Unfortunately, the headers and library it uses AREN'T ANSI compliant.
For example, stdio.h declare sprintf as returning char * rather than
int.  Sigh.
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
Domain: lawrence.jones@sdrc.com               IBMMAIL: USSDR7DR at IBMMAIL
Temporary insanity!  That's all it was! -- Calvin
From: qding@uoft02.utoledo.edu
Newsgroups: comp.lang.c
Subject: Help: problem codes
Date: 31 Aug 92 00:31:08 EST
Organization: University of Toledo, Computer Services


Hi, there.
I have a C program (shown below) which shows error
of >> Illegal structure operation in fuction sum. But I just
do not understand what's wrong with it. Can some one help out of
this please ?

C codes ----


typedef double tuple[4];

typedef struct vector {
	integer      dim; /* the dimension of the vector */
	tuple        component; /* the array of components */
} vector; /* the definition of type vector */

/* function sum */
vector sum(vector a, vector b)
{
   integer      i;
   sum.dim = a.dim;
   for (i = 1; i <= a.dim; i++)
   sum.component[i] = a.component[i] + b.component[i];
} /* function sum */
From: jfw@ksr.com (John F. Woods)
Newsgroups: comp.lang.c
Subject: Re: strcpy implementation question
Date: 1 Sep 92 15:43:14 EDT

jfw@ksr.com (John F. Woods) writes:
>>Well, NOT fine, if you were trying to write strictly conformant ANSI
>>C code. An ANSI C implementation is well within its rights to dump core
>>if you reference uninitialised memory
>Can you provide a reference for this?  I thought so too, but when I looked
>through the standard to back up MY reply, I found only the stipulation that
>uninitialized automatics have an "indeterminate" value; I couldn't find
>any permission for that value to cause any trouble.

I have been corrected on this.  The definition of "Undefined Behavior" lists
use of indeterminate values as an example of "Undefined Behavior...for which
the standard imposes no requirements."

My favorite paragraph in the WHOLE standard, and I forgot to check it!  Darn!
From: kevin@cfctech.cfc.com (Kevin Darcy)
Newsgroups: comp.lang.c
Subject: Re: why execve() call wouldn't return to the calling program?
Keywords: execve, unix, process
Date: 1 Sep 92 22:37:28 GMT
Organization: Chrysler Financial Corp., Southfield, MI

In article <15277@ksr.com> jfw@ksr.com (John F. Woods) writes:
>ih96@sol.acs.unt.edu (Yu Zhi) writes:
>>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.
>
>The easiest way around it is to ensure that the program you call with execl()
>does not exist, thus enabling execl() to return to your program with an error
>code.

BA-DA-BUMP! But seriously, folks...

>execl() is *supposed* to work the way you see.  It *replaces* the current
>process image with a new program.
>
>It sounds like what you really want is "system()" (check your friendly
>neighborhood manual set).

If you actually want to suck the output of your Fortran program into your
C program, popen()/pclose() might be a better choice.

Then again, if you really want to get down to the nitty-gritty, you could
use a combination of a fork() & an exec() call, possibly preceded by a pipe()
call. You'd probably want to go this route if performance is a critical 
concern, or if you want your C program to continue processing while the
Fortran program runs (watch out for synchronization/concurrency problems,
though). The fork() + exec() route is more work, though. System() or popen()
are generally easier to use, and harder to screw up.

------------------------------------------------------------------------------
kevin@cfctech.cfc.com 		  | Kevin Darcy, Unix Systems Administrator
...destroyer!cfctech!kevin 	  | Technical Services (CFC)
Voice: (313) 759-7140 		  | Chrysler Corporation
Fax:   (313) 758-8173 		  | 25999 Lawrence Ave, Center Line, MI 48015
------------------------------------------------------------------------------
Xref: sparky comp.lang.c:12855 comp.programming:2498
From: juul@diku.dk (Anders Juul Munch)
Newsgroups: comp.lang.c,comp.programming
Subject: Re: A LITTLE BRAINTEASER... -- generalized
Date: 25 Aug 92 17:02:09 GMT
Organization: Department of Computer Science, U of Copenhagen

aet@mullian.ee.mu.OZ.AU (bert thompson) writes:
[...]
>the rules of the game are you can use anything but data structures, or more
>specifically you cannot use the heap.
[...]
>can we make do using only the stack? do any functions require more?
>(non-primitive recursive functions like ackermann's -- just guessing. 8^)

>apologies if this question turns out to be really easy.

You are asking if C without heap allocation is Turing equivalent. I think it
is.

Here's a memory allocator that allocates off the stack...

typedef struct mem { DATA d; struct mem* next; } MEM;

void stackalloc(int cnt,MEM* tail, void (*fn)(MEM*))
{
  if(cnt == 0)
    fn(tail);
  else
  {
    MEM m;
    m.next = tail;
    stackalloc(cnt-1,&m,fn);
  }
}

How to write accessor functions
	DATA At(MEM*,int loc);
and	void AtPut(MEM*,int loc,DATA val);
should be obvious.

When you need n units of storage, you just call
	stackalloc(cnt,NULL,my_memory_consumer);
my_memory_consumer is a continuation function that uses the memory
allocated (circumventing the problem that the memory cannot be returned
directly due to stack unwinding with dangling pointers). Using
continuations is impractical, but I don't think it's a serious restriction.
Further arguments to the continutiations could easily be passed through a
modificed `stackalloc'.
  Ackerman's function is certainly no problem (just a lot of work).

Anders Munch		|  Department of Computer Science
juul@diku.dk		|  University of Copenhagen, Denmark
"Confused? The thing is to get confused at a higher level" - Jorgen Thorslund
Newsgroups: comp.lang.c
From: jutta@opal.cs.tu-berlin.de (Jutta Degener)
Subject: putenv() (was: Re: main())
Organization: Techn. University of Berlin, Germany
Date: Thu, 3 Sep 1992 12:59:44 GMT

chupchup@ferkel.ucsb.edu (Robert Earl) writes:
> [char ** envp is] very rarely used in UNIX, particularly,
> because the startup routine stuffs envp in a global variable called
> "environ", probably so main() doesn't have to do it all the time.
> But "environ" doesn't exist in ANSI only getenv() and putenv(),
> and this is comp.lang.c.  :-)

Note that the only place where putenv() exists "in ANSI" is in
the rationale (which is not part of the Standard) in the sentence:

  "A corresponding _putenv_ function was omitted from the Standard,
   since its utility outside a multi-process environment is questionable, 
   and since its definition is properly the domain of the operating
   system standard."

A colleague of mine just heaved his new "Advanced Programming in
the UNIX Environment" by W. R. Stevens from the stack of books
on his desk and suggested I mention the fact that XPG3 includes
putenv() (and a lot of other things like clearenv() and unsetenv()),
and that it was considered as an amendment to POSIX.1, and is
implemented both in SVR4 and newer versions of 4.3 BSD, but, this
being comp.lang.c, I politely declined.  (Good book.)

--Jutta
From: ark@alice.att.com (Andrew Koenig)
Newsgroups: comp.lang.c
Subject: Re: Freedom of Speech (was: Mister Ed Nilges)
Date: 31 Aug 92 13:31:35 GMT
Article-I.D.: alice.23593
Reply-To: ark@alice.UUCP ()
Distribution: usa
Organization: AT&T Bell Laboratories, Murray Hill NJ

In article <92243.054650IP25179@portland.caps.maine.edu> IP25179@portland.caps.maine.edu writes:

>   Keep in mind also that there are many versions of C (and C++) out there.
>   Some of us have to program in several of them, and NOT ALL OF THEM HAVE THE
>   SAME OPERATOR PRECEDENCE.

Really?  Can you give me an example of two compilers with different precedences?
-- 
				--Andrew Koenig
				  ark@europa.att.com
Newsgroups: comp.lang.c
From: fcw@telecom.ti.com (Fred Wedemeier)
Subject: Re: Freedom of Speech (was: Mister Ed Nilg
Reply-To: fcw@telecom.ti.com
Organization: TI Telecom Systems, Dallas
Date: Fri, 28 Aug 1992 21:05:45 GMT

In article 18631@Princeton.EDU, egnilges@phoenix.Princeton.EDU (Ed Nilges) writes:
> In article <BtnLup.Irz@NCoast.ORG> cmort@ncoast.org (Christopher Morton) writes:
> >
> >Your algorithm works out to:
> >
> >if(!(totalitarian_system)
> >  {
> >    piss;
> >    moan;
> >    whine;
> >    cry;
> >   }

> > {flame} there's a
> > stupid blunder in the above pseudo-C code.  Can you spot it?  {flame}

> 
> Give up?  The error, of course, is an unbalanced set of parentheses on
> the first line.  The second left parenthesis, behind the ! "not" symbol,
> is not needed, but incompetent programmers often overuse parentheses
> {flame}

You're right, of course, that parens may not be required when
precedence rules are applied to expressions. The next person reading
the code might not have a thorough-enough knowledge of these rules to
immediately understand exactly what the expression means. In
non-obvious cases, I expend maybe 0.2 seconds to put a () pair in an
expression, to perhaps save the next person from grief by
misinterpreting what I've written. I appreciate it when other
programmers return the favor, as long as they don't go overboard. If
you're writing product-quality software, making it work is only part of
the job. Making its source code readily understandable (i.e. part of
making it maintainable) is another. Bytes on a disk are cheap -
programming labor ain't.

---
Fred Wedemeier    pho: 214-997-3213     fax: 214-997-3639
                timsg: fcw             inet: fcw@pioneer.telecom.ti.com

Newsgroups: comp.lang.c
From: RICHARD@CLYDE.ttt.kth.se
Subject: Re: printf question
Organization: Department of TeleTransmission Theory
Date: Thu, 27 Aug 1992 19:18:50 GMT

In article <1992Aug27.143434.26965@dartvax.dartmouth.edu> eht@coos.dartmouth.edu (Edward H. Truex) writes:

   Hi all, 

   I am trying to format a hexadecimal number whose width 
   is always a constant - like 

	   printf("%04x\n", address );

   The problem comes in trying to use a #define'd macro to replace 
   the '4' in the above format string.  What I have done is

   #define ADDR_BITS 16

try:

printf("%0*x\n", ADDR_BITS/4, address);

Works like a charm! You could even make a macro:

#define outaddr(address) printf("%0*x\n",ADDR_BITS/4,(address))

--
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
! Richard Levitte, System manager       ! tel: int+46-8-790 64 23           !
! Royal Institute of Technology         ! fax: int+46-8-791 76 54           !
! Department of Teletransmition Theory  ! Internet: richard@ttt.kth.se      !
! S-100 44 Stockholm, Sweden            !                                   !
!---------------------------------------------------------------------------!
From: RICHARD@BONNIE.ttt.kth.se
Newsgroups: comp.lang.c
Subject: Re: Some help requested
Date: 23 Aug 92 22:07:17 GMT
Organization: Department of TeleTransmission Theory

Two ways:

	int i;
	char s[9];
	fscanf (file, " %d , %8s", i, s);

or (if you have already read the line into a string called, say, line):

	char s[9];
	char *p = strchr (line, ","); /* donot remember the order of the args */
	if (p != NULL)
	  {
	    for(p++; *p == ' '; p++);
	  }
	
	strncpy (s, p, 8);
	s[8] = '\0';

enough?
--
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
! Richard Levitte, System manager       ! tel: int+46-8-790 64 23           !
! Royal Institute of Technology         ! fax: int+46-8-791 76 54           !
! Department of Teletransmition Theory  ! Internet: richard@ttt.kth.se      !
! S-100 44 Stockholm, Sweden            !                                   !
!---------------------------------------------------------------------------!
Newsgroups: comp.lang.c
From: stan@sabaac.NoSubdomain.NoDomain (Andrew Staniszewski)
Subject: Help on Signals
Reply-To: staniszewski@mayo.edu
Organization: Mayo Foundation
Date: Mon, 31 Aug 92 21:26:37 GMT

I am trying to catch SIGFPE's  in my source, but it doesn't look like the signal
ever gets raised. I am running DEC ultrix. anyone who can tell me the why and how
of generating SIGFPE,
I am much obliged

AJS
Newsgroups: comp.lang.c
From: tsv@dbrus.Unify.Com (Tim Vannaman)
Subject: dBase III libraries
Organization: unify
Date: Sat, 29 Aug 92 19:47:21 GMT

Does anyone have any libraries/source code that read/write dBase III files?
I created my own, but it seems that everyonce in a while a field would countain
a NULL value.

PS.  Maybe a list of pitfalls to look out for would be good enough to point me
in the right direction!

Thanks,

Tim.
--
Tim Vannaman, Premium Technical Support Engineer   Phone: (916) 928-6433
Unify Corporation, Sacramento, California    Fax: (916) 928-6403
tsv@unify.Com  or  {{ucdavis,csun,lll-crg}!csusac,pyramid,sequent}!unify!tsv
From: benrg@ocf.berkeley.edu (Ben Rudiak-Gould)
Newsgroups: comp.lang.c
Subject: How can I multiply and divide 32-bit fixed-point numbers?
Date: 1 Sep 1992 10:40:53 GMT
Organization: U.C. Berkeley Open Computing Facility
NNTP-Posting-Host: tornado.berkeley.edu

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?  For multiplication, I could do

(a>>8) * (b>>8)

but that loses (ignores) the lower eight bits of precision of both
variables (which might be significant).  Division is even worse; the best
I can come up with is

(a / (b>>8)) << 8

but then not only do I lose eight bits of b, I also always end up with a
result that is truncated to 8 bits of fraction, far less than the 1/65536
precision I should be able to get.

What's most annoying about this is that I know that the uP I'm using
(i486) returns 64-bit results to 32-bit multiplies and divides, but
C won't let me access them.

Is there any solution short of inline assembly?

Thanks.

--
Ben Rudiak-Gould
benrg@ocf.berkeley.edu
Newsgroups: comp.lang.c
From: Bob Zigon <bobz@truevision.com>
Subject: Problems with MSC7.0 and Intel 302 box
Organization: Truevision, Inc., Indianapolis, IN
X-Useragent: Nuntius v1.1
Date: Fri, 28 Aug 1992 14:08:48 GMT

I am having a great deal of difficulty getting MSC7.0 to run on an Intel
302 box.
This is a 25mhz 386 machine. My tests are showing that there is something
strange
about the hardware that is preventing the C compiler from running under
DOS 5.0.
The C compiler (CL) reports the message "R6906 : DOSX32 - not enough
conventional memory 
for exec". I have worked with Qualitas (makers of 386MAX) to see if they
can help. No luck.
Microsoft is also looking into the problem. There must be something funny
about the
machine. I say this because the DOS directory where DOS 5.0 is installed
has a README
that "singles out" the Intel 302 box whenever you install HIMEM.SYS. You
must include
a /MACHINE:8 parameter to HIMEM.SYS.

Anyone got any ideas?
From: chuckb@milton.u.washington.edu (Chuck Bass)
Newsgroups: comp.lang.c
Subject: Re: Most difficult part of learning C?
Date: 25 Aug 92 22:28:15 GMT
Organization: University of Washington

I think that often times things that are difficult to learn
about a language are really caused by not knowing much about
programming.  If the concept of a pointer is not somewhat clear
then using scanf will be "difficult".  Not because of C but
because of not understanding a concept that C is based on.  

I would bet that assembly language programmers have no problem
picking up C's notion of pointers.  I admit that for me pointers
and arrays, and pointers to char took a while to understand.  I
attribute this to the fact that before C I knew a bit of basic
and a bit of Scheme.  Two languages where pointers were not
introduced to me.

Anyway,  I found precedence and type casting to be very
confusing.  I still use cdecl if there is any question when I
need a pointer to a function returning pointer to ...........

Just my 0.02...


Chuck Bass
College of Forest-Systems Engineering
University of Washington
chuckb@u.washington.edu
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Newsgroups: comp.lang.c
Subject: Re: main()
Date: 2 Sep 92 21:43:31 GMT
Organization: University of Helsinki

harrison@lclark.edu (Mark Harrison) writes:
>In my programs, I use 'void main()' and never had any problems doing so. 

The age-old wisdom of "it works for me, so it must be correct".  Trust
me, ``void main'' is not correct, and the fact that it works is an
unfortunate accident and sloppiness on the part of the compiler writer
(most compiler writers seem to be sloppy in this regard).

--
Lars.Wirzenius@helsinki.fi
Newsgroups: comp.lang.c
From: krc@wam.umd.edu (Kevin R. Coombes)
Subject: Re: True Portability?
Organization: University of Maryland, College Park
Date: Wed, 2 Sep 1992 13:13:33 GMT

fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
>jlnance@eos.ncsu.edu (JAMES LEWIS NANCE) writes:
>>
>>If you write binary files and expect to share these between machines,
>>or if you use network connections between machines, then you have to
>>wory about wheather a machine is big or little endian, but if you
>>explicitly take this into account, you can still be portable.
>
>No, you won't.
>Basically binary files are not portable.
>(Code to read/write binary files can be portable, but the files themselves
>are not.)
>

I'm not sure I understand this statement. Yesterday I transferred some
DVI files (produced by TeX) and some MAT files (produced by Matlab)
from my Sun at work to my PC at home. I was still able to print the
DVI files, and to load the MAT files and continue my computations.

Both those files are binary data files used by the programs I mentioned.
Clearly, they are portable, since implementations of the software for
different platforms can both use them. Yes, the software has to be ported
as well; that's not in question. Could you elaborate on what you mean
when you say that binary files are not portable?

Kevin Coombes <krc@math.umd.edu>
From: emarkp@ocf.berkeley.edu (E. Mark Ping)
Newsgroups: comp.lang.c
Subject: How to randomly access files in C?
Date: 1 Sep 1992 00:18:50 GMT
Organization: U.C. Berkeley Open Computing Facility
Distribution: world
NNTP-Posting-Host: plague-ether.berkeley.edu


  The subject line pretty much says it all.  Basically, I'm reading a file
with fgets, and I want to be able to 'go back' a few lines if a certain
condition is true.

  If I were going through a char array, I'd have two pointers, and would
reset the second if the condition were true, i.e.:

main()
{
	char line[]="This is a test line."
	char *a, *b;

	a = line;
	b = a;

	while (*a != NULL)
	{
		if (foo(a))
		{
			a = b;
		}
		else bar();
		b = a;
		a++;
	}
}

  Now how can I emulate that behavior with successive lines in a file?
(Sorry if the above code is somewhat icky, it's just a random example to
clarify the question.)

  Thanks for any help.
-- 
E. Mark Ping
emarkp@ocf.Berkeley.EDU

  "Stand aside, I take large steps."    --Michael Dorn
  "Say, that's a nice bike."            --Cyberdyne Systems T-1000
  "Pituita es."                         --Unknown Latin Scholar

And of course, this in no way reflects my views of UC Berkeley.
From: mike@pacsoft.com (Mike Stefanik)
Newsgroups: comp.lang.c
Subject: Re: main()
Date: 3 Sep 92 18:04:13 GMT
Organization: Pacific Software Group, Riverside, Ca.

In an article, jaorans@PacBell.COM (Jeff Oransky) writes:
>I would have to guess that the custom of making the main function an int
>type and returning 0 at the end is more of a necessity in UNIX C 
>programming since a program return to the operating system of 0
>indicates a successful execution or a non zero for an unsuccessful one.

Some operating systems (such as VMS) consider a returned value of 0 to
indicate an error.  Consider these two programs:

	main(void)
	{
		printf("Hello, world!\n");
		return 0;
	}

	main(void)
	{
		printf("Hello, world!\n");
		exit(0);
	}

The first case will return and VMS will complain about a (benign) error; in
the second case, the exit() function knows that passing a value of 0 means
"no error", and terminates the program correctly.

Has there been any standardization efforts in regards to the exit status
returned by programs?  For example, to be POSIX compliant, is it required
that a program be able to (a) return a numeric status to the parent process,
and (b) a status of 0 always indicates no error?

-- 
Mike Stefanik  mike@pacsoft.com  ...!uunet!pacsoft!mike
Pacific Software Group, Riverside, CA
From: dliao@sal-sun111.usc.edu (David Liao)
Newsgroups: comp.lang.c
Subject: Borland C++ 3.1 and AF - $395
Date: 28 Aug 1992 13:26:19 -0700
Organization: University of Southern California, Los Angeles, CA
Distribution: world
NNTP-Posting-Host: sal-sun111.usc.edu

  
                =========================================
                For sale:

                BORLAND C++ 3.1 and APPLICATION FRAMEWORK 

                $395.00 (shipping included)

                =========================================



Sorry to post this forsale thing here, but I need to get rid of my
Borland C++ 3.1 and Application Framework soon.  I had a problem with
my financial aid and I need to come up with some money before my tuition
deferment date.  I got Borland C++ 3.1 and AF last week from mail order
for $595 (retail $795.)  I got this package for my C++ programming class
this fall, but paying the tuition is more important now.  I haven't opened 
this package, since my programming class hasn't started yet.  I'm going
to sacrifice this for $395 (shipping included).  My friend told me this has
everything you need for developing C++ applications.  

Again sorry for posting it here...

dliao@aludra.usc.edu
From: albert@bsovax.UUCP (Albert van der Horst)
Newsgroups: comp.lang.c
Subject: How to handle __STDC__
Keywords: ANSI C, prototypes
Date: 28 Aug 92 10:51:49 GMT
Organization: BSO/AT Utrecht bv., P.O.Box 8052, 3503 RB UTRECHT, The Netherlands

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?

                                Thanks, Albert
--
"If it weren't for Salt-N-Peppa, I wouldn't make it through midlife crisis"
           Albert van der Horst    BSO/Automation Technology
           P.O 8052  3053 RB   UTRECHT       The Netherlands
           uunet!sun4nl!bsovax!alcohux!albert
Newsgroups: comp.lang.objective-c