HDTenEightyP/NetNews huggingface dataset:
From: dfuller@portal.hq.videocart.com (Dave Fuller)
Subject: Re: Someone help me with this
Organization: VideOcart Inc.
X-Newsreader: Tin 1.1 PL3
Date: Sat, 7 Nov 1992 01:03:15 GMT

jmwojtal@vela.acs.oakland.edu (Wojo) writes:
: 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;
: 
-----------------------------------------------------------------
chances are you get a null dimension error. what you need to do to clear
this up without changing any of your data types is fairly simple.
in getday make (char holdday[][]) this (char holdday[][31])

this should be all you need. it would be nice if you used #defines to 
be sure about sizes staying in sync if 1 changes, but this is purely
your choice.

you need a value in the second brace because of the way 2-d arrays are
handled. with a value, the compiler can figure the offset between the 
elements in the array.


Dave Fuller
dfuller@portal.hq.videocart.com

Newsgroups: comp.lang.c
From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
Subject: Re: How to use 'return' in c?
Organization: Texas Instruments Inc
Date: Thu, 12 Nov 1992 16:41:43 GMT

In <7162TB3w165w@quest.UUCP> kdq@quest.UUCP (Kevin D. Quitt) writes:

>mccall@mksol.dseg.ti.com (fred j mccall 575-3539) writes:

>> In <gm5XTB3w165w@quest.UUCP> kdq@quest.UUCP (Kevin D. Quitt) writes:
>> >    On the other hand, since C does not truly support the boolean type,
>> >I consider it misleading to assign a numeric value to a boolean.  I
>> >define TRUE as (1==1) because the result of this is a boolean - the
>> >fact that it is represented by a numerical value is misleading.
>> 
>> No, the result of this is *1*.  If it is anything else, your compiler
>> is seriously broken.

>    No, the result is *represented* by a 1.  "1" is not a boolean value.
>TRUE is a boolean value that requires a numeric definition because of
>the limitations of the language.  Other languages have booleans and do
>not allow assigning numeric values to booleans.  (On the other hand,
>most of *those* languages are otherwise so broken as not warrant their
>use.)

Note that the name of the group is comp.lang.c.  C does not have
'boolean' type.  The result *IS* a 1.  The result is NOT *TRUE*,
because in C 'true' is any non-zero number.

-- 
"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: dougv@vnet.ibm.com (Doug Valkenaar)
Date: Fri, 13 Nov 92 11:27:53 PST
Newsgroups: comp.lang.c
Subject: ANSI-C crossreference program needed
Reply-To: exit
Organization: ROLM
Disclaimer: This posting represents the poster's views, not those of IBM
News-Software: UReply 3.0

I was wondering if anyone knew of an ANSI-C crossreferencing program available.
I tried 'cxref' but it's not quite what we want.  We need to be able to specify
an include path, use ANSI-C code, see the definition in the output, have
the context of the reference available.

Any help on this would be greatly appreciated.

----------------------------------------------------------------------
D. Douglas Valkenaar       ROLM PhoneMail         (dougv@vnet.ibm.com)
----------------------------------------------------------------------
Newsgroups: comp.lang.c
From: gurgle@netcom.com (Pete Gontier)
Subject: Re: THINK C problem
Organization: cellular
Date: Sun, 8 Nov 1992 02:51:17 GMT

Frank_E_Stock@cup.portal.com writes:

>a bit of trivia for you, THINK C will not allow you to mix stdio call with
>Macintosh toolbox calls in the same program.  I know its pretty lame.  If you

Sorry, not true. I've done it. The down-side is that you have to know
enough about Mac programming and the compiler to stay out of the stdio
library's way, but it *is* possible.
-- 
 Pete Gontier // EC Technology // gurgle@netcom.com
From: Neal.Sanche@ttlg.UUCP (Neal Sanche)
Sender: postmaster@ttlg.UUCP
Newsgroups: comp.lang.c
Subject: Orbit Simulation
Date: 10 Nov 92  22:28:08 mst

I am looking for source code for orbit simulation in C. Basically
this would be the two body dynamic simulation of say Earth and a
satellite. I have mathematically figured out the equations necessary
but I am having a lot of problems with floating point overflows
and so on. Are there tricks for staying withing the floating
point limit of the machine?

Thanks for any help you can give.

Please send replies to neal@manning.cs.ualberta.ca

-Neal
___
 X OLX 2.1 TD X "Build a watch in 179 easy steps" by C. Forsberg.

 * Origin: Paradigm BBS: A programmer's paradise. (42:100/11)
Newsgroups: comp.lang.c
From: tombaker@world.std.com (Tom A Baker)
Subject: Re: (SOLUTION) How to print an integer as binary?
Organization: Me, at The World Public Access UNIX, Brookline, MA
Date: Fri, 6 Nov 1992 12:08:15 GMT

In article <1992Nov4.180622.6568@csd.uwe.ac.uk> th2_oate@csd.uwe.ac.uk (Tom Oates) writes:

TO> Assuming that:- 
TO> 
TO> int i = 203;
TO> 
TO> How do I display 'i' as 11001011?

  I am amazed at the timing, a coincidence ... I've just completed a
package to do this, and used it on a  project on Forward Error
Correcting Codes.  It provides for constants (either "11001011",
"b11001011", or "0b11001011" (I prefer the last)), and converting
to and from strings to and from integers, and to floats (1-1/2
becomes "1.1" in binary).

  Once I put it together this weekend, I'll be glad to mail it to
requestors, and may pop it onto comp(or *).sources .

  Incidentally, the string routine you specifically asked about uses
the algorithm:

    1) Convert to octal string.

    2) Convert THAT to binary characters.

    3) Use a "while()" loop to get rid of the leading zeros.

tombaker@world.std.com
From: kdq@quest.UUCP (Kevin D. Quitt)
Newsgroups: comp.lang.c
Subject: Re: How to use 'return' in c?
Date: Sun, 08 Nov 92 16:31:03 PST
Reply-To: srhqla!quest!kdq
Organization: Job quest  (805) 251-8210,  So Cal: (800) 400-8210

darcy@druid.uucp (D'Arcy J.M. Cain) writes:

> allebrandi@ipact.com writes:
> >The best thing to do is to use manifest constants to implicitly document
> >the value you are returning. For example, return TRUE or FALSE not 1 or
> >0 for a boolean function return.
> 
> Whenever I see TRUE and FALSE in code I am maintaining I remove the
> #defines.  If they are defined, they should never be anything but
> TRUE = 1 and FALSE = 0.  Anything else is confusing and misleading.

    On the other hand, since C does not truly support the boolean type,
I consider it misleading to assign a numeric value to a boolean.  I
define TRUE as (1==1) because the result of this is a boolean - the
fact that it is represented by a numerical value is misleading.

 _
Kevin D. Quitt                                 Job Quest (805) 251-8210
srhqla!quest!kdq                               Learn How to Get a Job in SoCal

                96.37% of all statistics are made up.
From: kdq@quest.UUCP (Kevin D. Quitt)
Newsgroups: comp.lang.c
Subject: Re: The Correct Way To Write C if-Statements
Date: Sun, 08 Nov 92 12:11:47 PST
Reply-To: srhqla!quest!kdq
Organization: Job quest  (805) 251-8210,  So Cal: (800) 400-8210

    The only reasonable way I've ever found to maintain code appearance
consistency within a group is to use Gnu's indent or other reformatter.
When a person checks in his/her code, it's run through indent with a
preselected set of parameters to control the format.  Thus, any code
checked out will be uniform in appearance.

    On the other hand, since this annoys the programmers who have their
own style, there's an option that lets them have the check-out process
automatically reformat a piece of code using their selected parameters.

    This way keeps the programmers happy, and keeps whoever decided
there needs to be a consistent style happy.


 _
Kevin D. Quitt                                 Job Quest (805) 251-8210
srhqla!quest!kdq                               Learn How to Get a Job in SoCal

                96.37% of all statistics are made up.
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Newsgroups: comp.lang.c
Subject: Re: The %lf format specifier.
Date: 6 Nov 92 20:11:25 GMT
Organization: University of Helsinki

yngvar@imr.no (Yngvar Foelling) writes:
>My question is: Is the %lf specifier really illegal in printf?  

It is definitely non-standard.

>In that case, why _does_ the standard define specifiers like %hd for
>short, when short is always expanded to int?

What happens is that the short value is promoted to an int before the
function is called, but the function converts it back before printing it
out.  This has implications for at least the u, o, X, and x formats,
where the value is actually converted to an unsigned.  For example, if
you pass -(short)1 as the argument (which is an OK thing to do), the
function gets -1 (a signed int) and convertes it to an unsigned short. 
If it couldn't convert it to short, but had to use int, and if ints are
longer than shorts, the value printed out would be different. 

Try this on a machine with ints that are larger than shorts:

	printf("%x\n", -1);
	printf("%hx\n", -1);

For example, on a two's complement machine with 16-bit shorts and 32-bit
longs, the output is:

	ffffffff
	ffff

If there were no %hx, it wouldn't be possible to obtain the latter
output.

I have no idea why %hd exists, though, unless it is because of
orthogonality.

--
Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
   MS-DOS, you can't live with it, you can live without it.
Newsgroups: comp.lang.c
From: rcd@raven.eklektix.com (Dick Dunn)
Newsgroups: comp.lang.c,comp.software-eng
Subject: Will we keep ignoring this productivity issue?
Summary: CAN we afford to ignore it?
Date: 11 Nov 92 05:51:30 GMT
Followup-To: comp.software-eng
Organization: eklektix - Boulder, Colorado

This was in the "productivity of a C programmer" thread, about a week ago.
I haven't seen anyone picking up on it--esp. in comp.software-eng, where it
damned well *should* generate discussion!  Bob Munck (munck@stars.reston.
unisys.com) wrote:

>...However, it is a fairly-well-established rule of thumb that
>very good programmers can be an order of magnitude or more productive than
>the average and do a good job...

We toss this number around a lot.  A couple years ago I tossed it at a
friend who does a lot of real-time, control-system, etc. programming...just
to test his reaction, since he's generally good for a strong opinion.  But
his retort came from a direction I hadn't expected: he said "It's more like
*two* orders of magnitude!  You get the first order-of-magnitude difference
when the code is written.  The second comes during maintenance."  (Cf. also
Mark Terribile's comments about changes being made to the best code, because
it's the code people can figure out how to change.)

Well, maybe the difference is an order of magnitude, maybe two.  Be very
conservative, go below the geometric mean; assume it's only a factor of 20.

*ONLY*???

How *can* we afford to be off pondering complexity metrics, bantering about
25% changes, gaping in awe at the occasional arguably-possible factor of
2, when there's this sort of fundamental difference that's been staring us
in the faces for the past several decades?

How many software businesses can really afford to ignore such large factors
in development cost?  Can they really afford (say) the difference between
$150,000 and $3 million in development cost? and even if they can, can they
afford the extra time-to-market?

>...I've always felt that the path to **IMPROVING
>SOFTWARE PRODUCTIVITY** should start with an investigation of why that's so and
>how to take advantage of it.  Instead, we are spending $hundreds of million$ to
>lower the skill level needed for programming.

Or, if I may reword what Bob said rather less kindly, we are spending vast
sums to get code out of the people who can't program, instead of finding
out how the folks who can program do it.

In fact, I suspect we'd even be better off just letting those who can, do,
and not pretending that those who can't, can.  "Negative productivity" is
too well known; if we weren't sending some fair fraction of our best pro-
grammers off to clean up the disasters created by some of our worst pro-
grammers, we'd have enough real skill to go around.

[To forestall some of the obvious criticism: I refer to a "programmer" as a
person who constructs programs--the whole things, doing what they're
supposed to do, with all the associated documentation.  I don't mean a
"coder" or a hacker of binary arcana.]
-- 
Dick Dunn    rcd@raven.eklektix.com   -or-   raven!rcd    Boulder, Colorado
	...Simpler is better.
Newsgroups: comp.lang.c
From: atbowler@thinkage.on.ca (Alan Bowler)
Subject: Re: Binary Representation
Organization: /etc/organization
Date: Fri, 13 Nov 1992 22:23:36 GMT

In article <1992Nov5.222742.7875@unislc.uucp> ttobler@unislc.uucp (Trent Tobler) writes:
>Ray Mitchell (mitch@nosc.mil) wrote:
>: 
>: It seems that since C has bitwise operators and its treatment of pointers
>: is so close to the underlying hardware, there should be a way of representing
>: constants in binary in addition to decimal, hex, and octal.  Does anyone
>: know why this was not done?  Maybe I'm the only one who sees any value in
>: it.  (Please don't tell me to use assembly if I want binary).  I've
>: contemplated some macro way of implementing a binary representation but
>: have not come up with anything reasonable.  Any ideas?
>
>
>Probably the reason for not including binary in the C language is that
>binary tends to be long and bulky... and it is trivial to convert binary
>to hex or octal in ones head.
>
Which of course is the same reason that most assemblers don't bother
with binary either, and give you hex and octal contants to build
bitmasks with.

Newsgroups: comp.lang.c
From: misar@rbg.informatik.th-darmstadt.de (walter misar)
Subject: Re: Returned struct
Date: Fri, 6 Nov 1992 16:29:10 GMT
Organization: TU Darmstadt

In article <Bx9pJE.Et4@portal.hq.videocart.com>, dfuller@portal.hq.videocart.com (Dave Fuller) writes:

> As i said, you can pass structures with some compilers, but if you want 
> to do this the 'right' way, pass the pointers to them instead.

The ANSI standard explicitly allows structures to be assigned by structs,
passed as function arguments and to be returned by functions. Problems will
omly arise, if you compile the code on one machine, and link it on another,
because some compiler pass a pointer if a struct is used as argument, while
other put thw whole struct on the stack.

Organization: Applications Software, Carnegie Mellon, Pittsburgh, PA
Newsgroups: comp.lang.c
Date: Mon,  9 Nov 1992 16:47:05 -0500 
From: Richard Dale Romero <rickr+@CMU.EDU>
Subject: Re: Printing out trees
	<BxG3py.LoA@cck.coventry.ac.uk>

No, that's not really what I meant--I meant in a formatted way
so that I could tell what the child-parent relations were...

I did think of an acceptable way, if anyone cares to know.
You need to have a queue implementation also, which
isn't hard to do, though, and if you try to queue a null
node, it just doesn't queue anything.

Step 1)  Assign every node it's in-order numbering,
	node->number, and a depth variable, node->depth
	This is the one where you number your left
	children, number yourself, then number
	your right children (at least I think this
	is the in-order traversal :-)

Step 2) Queue the root of the tree

Step 3) Start while loop that stops when queue is empty

Step 4) De-queue top element, and if this element is at a
	different depth than the previous one, print
	newline, and set cur_x = 0

Step 5) Queue it's left child, then right child

Step 6) Space over (cur_node->number - cur_x) "blocks"

Step 7) Print current node value, then set
	cur_x = cur_node->number + 1

Step 8) End of while loop.

At least, I think that's what my code does....

Regardless it will print out a node such that its direct children
are on the line directly below it, *every* item in the left
sub-tree appears to the left of the current node, and *every* item
in the right sub-tree appears to the right of the current node.

-rick
From: dalessan@clam.rutgers.edu (Gene Gino The Gene-man)
Newsgroups: comp.lang.c
Subject: Error redirection
Date: 9 Nov 92 05:04:01 GMT
Organization: Rutgers Univ., New Brunswick, N.J.

How would I go about redirecting the error, so I can display
my own.  i.e If the user tries to ammend(>>) or chmod or anything
else that causes an error from the machine (Permission denied etc).

Gene
From: anb@doc.ic.ac.uk (A N Burton)
Newsgroups: comp.lang.c
Subject: Re: How to print an integer as binary?
Date: 5 Nov 1992 18:33:44 GMT
Organization: Department of Computing, Imperial College, University of London, UK.
Distribution: world
NNTP-Posting-Host: mfast.doc.ic.ac.uk

In article <1992Nov4.180622.6568@csd.uwe.ac.uk> th2_oate@csd.uwe.ac.uk (Tom Oates) writes:
>Assuming that:- 
>
>int i = 203;
>
>How do I display 'i' as 11001011?
>
>
>
>
>-- 
>****************************************************************************** 
>* Tom Oates (Univ. of West of England) * DISCLAIMER:I speak only for myself. * 
>* Email to: th2_oate@uk.ac.uwe.csd     * PGP 2.0 Key available upon request. *
>******************************************************************************


The program appearing below gives three possible solutions; the first is for
those favouring recursion, the other two use loops.  The second scans the
number from right to left, and therefore uses an array to hold the partial
results.  Solution three scans from left to right and thus outputs as the
binary form is generated.


Ariel BURTON



#include	<stdio.h>


void
PrintBinary1( long x ){
	if ( x < 0 ){
		putchar( '-' );
		PrintBinary1( -x );
	}
	else if( x < 2 )
		putchar( '0'+x );
	else{
		PrintBinary1( x >> 1 );
		putchar( '0'+( x & 1 ) );
	}
}
#define MAX_SIZE 32
void
PrintBinary2( long x ){
	char	buff[ MAX_SIZE+1 ];
	int	i;

	if( x < 0 ){
		x = -x ;
		putchar( '-' );
	}

	buff[ i = MAX_SIZE ] = '\0';
	for( ; x ; x >>= 1 )
		buff[ --i ] = '0'+ (x&1);

	printf( "%s", buff+i );
}

void
PrintBinary3( long x ){
	unsigned long	mask = 1 << (8*sizeof(unsigned long) - 1);

	if( x < 0 ){
		putchar( '-' );
		x = -x;
	}

	for( ;  ! (x & mask) ; mask >>= 1 )
		;

	for( ; mask ; mask >>= 1 )
		putchar( x & mask ? '1' : '0' );
}

main( int argc, char *argv[] ){
	PrintBinary1( atol(argv[1] ) );
	putchar( '\n' );
	PrintBinary2( atol(argv[1] ) );
	putchar( '\n' );
	PrintBinary3( atol(argv[1] ) );
	putchar( '\n' );
}
Newsgroups: comp.lang.c
From: bandy@netnews.jhuapl.edu (Mike Bandy)
Subject: Re: HELP!!! Converting strings to floats....
Organization: JHU/Applied Physics Laboratory
Date: Sat, 7 Nov 1992 05:27:42 GMT

gtb6038@summa.tamu.edu (BILES, GREG THOMAS) writes:

>My major CPSC project is due today, and I have one big problem.  I have a 
>string that contains some number, ex 43.23489.  And, I want to convert that to
>a float.  I have tried to write it to a file and then read it in as a float,
>but it just adds some small number to the end.  For instance, 324.234 would 
>be read in as 324.23398342!  Thanks for any help in advance!

You're at the limits of a single precision number.  Either display fewer chars
on output of use a double precision number.


-- 

	Mike Bandy
	bandy@aplcomm.jhuapl.edu
	Johns Hopkins University / Applied Physics Lab
From: scotth@felix.filenet.com (Scott Hopson)
Newsgroups: comp.lang.c
Subject: Re: Fortran to C conversion: Why bother?
Date: 11 Nov 92 02:13:45 GMT
Reply-To: scotth@fritz.filenet.com (Scott Hopson)
Organization: FileNet Corp., Costa Mesa, CA

Keywords
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. All you end up with is C code that
>exactly mimics the functionality of the original fortran code. Its not as if
>the translating program rewrites your algorithms to use the parts of C that
>make C really useful. Its just fortran code expressed in C. What's the point?
>If you're going to write programs in fortran, use a fortran compiler. If you
>want to use the features of C, learn C and use a C compiler. Using f2c doesnt
>give you any of the advantages of designing and writing the original program 
>in C.

Let's say your company was moving from a system like an IBM running MVS or a 
DEC running VMS or some other similar beast to a Unix machine. You had lots of
OLD code which was written in FORTRAN but your new environment was going
strictly C and you knew there might be a need to maintain the OLD code, but you
lost all your Hard Core Fortran Oldtimers.

What would you decide to do?

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.

This is just one reason but I'm sure others can think of more..

:-)

Later Dudes....

-- 
Scott Hopson   (scotth@filenet.com)
From: elias@proxxi.uf.se (Elias M}rtensson (proxxi))
Newsgroups: comp.lang.c
Subject: Re: Recursion and the white book
Date: 5 Nov 92 15:09:17 GMT
Organization: proxxi

schwamb@isi.edu (Karl Schwamb) writes:



>One of my favorite indices is the one in Guy Steele's book "Common Lisp
>the Language", 2nd Ed.  The best of the lot, IMHO, is

>  kludges, 1-971

>but there's also plenty of stuff like:

>  Bubs, Floob-Boober-Bab-Boober, 461
>  crab, catching a, 191

>Maybe the index would make good bathroom reading...

Another favourite is the "see also" list in the manual page for
GNU-bash.

	"SEE ALSO
	     The Gnu Readline Library, Brian Fox
	     The Gnu History Library, Brian Fox
	Lennert
	     A System V Compatible Implementation of 4.2BSD Job Control, David
	     How to wear weird pants for fun and profit, Brian Fox"

>-Karl

######################
#   Elias Martenson  #
# elias@proxxi.uf.se #
######################
Newsgroups: comp.lang.c
From: craigh@cserver.plexus.com (Craig Heilman)
Subject: Re: The Correct Way To Write C if-Statements
Organization: Plexus Corp. -- Neenah Wisconsin
Date: Fri, 13 Nov 1992 21:52:31 GMT

goudreau@batman.rtp.dg.com (Bob Goudreau) writes:

[...]
>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.

Two spaces after a sentence is a throwback to the typewriter days when
everything was "monospaced" (ie. the width of each character is the same).
Two spaces looks better with such fonts (note how these net messages are
monospaced - at least on my machine).  Now if you type something in a
word processor and use "proportional" fonts (ie. the width of each
character depends on the character) you should never, repeat NEVER, use
two spaces after the period in a sentence.  Any publisher (printer, etc.)
will tell you this, and by the way my style manual (Webster's Standard
American Style Manual) says: "In typewritten material, two spaces follow
a period that ends a sentence. ... In typeset material, only one space
follows this period."

Cheers,
	Craig
--
*                           * "I just found out that the brain is like a   *
* Craig A. Heilman          * computer.  If that's true, then there really *
* craigh@cserver.plexus.com * aren't any stupid people.  Just people       *
*                           * running DOS." - VH1's Stand Up Spotlight     *