HDTenEightyP/NetNews huggingface dataset:
From: eli@csd4.csd.uwm.edu (Elihu Lubkin)
Newsgroups: comp.lang.c
Subject: Re: Problems with Case statements HELP!
Date: 15 Dec 1992 06:28:09 GMT
Organization: University of Wisconsin - Milwaukee
Distribution: usa
NNTP-Posting-Host: 129.89.7.4

jhurwitz@access.digex.com (j. hurwitz) writes:
: 
: Okay, I'm new to C so you'll have to forgive my lame question. Anyhoot,
: I'm trying to write a program that will check for balanced braces in my
: C source code.: But, when I try this:
: 
: ============================== Begin Hack =========================
: //programm to read a C source file and verify # of left to right braces
: 
: #include <stdio.h>
: int main(int argc, char *argv[])
: {
:    FILE *fptr;
:    int l=0, r=0;
:    char ch;
: 
:    fptr  = fopen("brachek3.c","r");
:    while ((ch =getc(fptr)) !=EOF)      
:    {
:    switch (ch)
:      {
:      case '{':  l++;
                  break;     <====otherwise { increments l & r; } only r. 
:      case '}':  r++;                       --Thelma
 
:      }
:    }
:    printf("\nl= %d r= %d", l, r);
:    if (l != r)
:    printf("\nBraces do not match\n");
:    else printf("\nBrace match !!!\n");
:    fclose(fptr);
: }
: ================================ End Hack ========================
: I get an uneven number of braces at the end. I can't figure out what
: I am doing wrong. I'm sure it is a minor oversight on my part. Any help
: would be greatly appreciated
:  
: 
: 
: 
:           __/ /          .                     +             .
:         _/__/_/\                                
:       _/____/ \/  J. Hurwitz                                          ,
:   .  /     / \/|          .          *                   
:     /     /  /|/  The MIDI master             .                  o
:    /_____/  / |                                         
:   //____/\\/ /  Roaming Cyberspace          "Space is the place"        
:   /  o  \ ||/    .                     
:  | o   o |//                                .          -Sun Ra      +
:   \o   o//     jhurwitz@access.digex.com          
:    --^--   .                                            *        
: +                         '               +                          
Newsgroups: comp.lang.c
From: richard@crowded-house.den.mmc.com (Richard Armstrong)
Subject: Re: What do you say.
Organization: Martin Marietta
Distribution: usa
Date: Fri, 11 Dec 1992 17:32:07 GMT

In article <1992Dec10.140334.15545@microware.com> adam@microware.com (Adam Goldberg) writes:
>allan@microware.com (R. Allan Kirkhart) writes:
>
>>	While working on a technical support line, I received a call from a 
>>frustrated customer.  During the course of the conversation, he told me
>>he had recently been hired as systems programmer, and that he had three
>>years experience programming in C.  Seems he had been set to the task of 
>>maintaining a large body of C source code.  His question......
>
>>	"They use this argv thing heavily and I was wondering if you could
>>	 explain what it is, and what it is used for?"

This does not amaze me. In fact, I find it quite possible that someone with
three years in C would have never been exposed to argv.  What if this person
had this three years experience in a Macintosh arena? There is no argv. In 
fact, there is no command line!  Even in any other environment, this programmer
may have never been exposed to argv. This is true for many features of the
language -- I have ten years experience, but still get stumped on features that
I have never used, or on features that I have used only a couple of times. For
instance, I have NEVER used a variable number of arguments in a function.
(excluding the argv from main()) I was once asked in an interview how I would
write a function with a variable number of arguments... Since I have never 
used this feature, and have only skimmed over the material that explains it,
I could not answer the question. But does this mean that this employer should
not hire me?  I am certain that if I ever need to use this feature, that I
could pick up a book and figure it out fairly quickly.  We should not be so
quick to judge another's weakness.  They may be far stronger in areas that we
are weak in.

>
>>>I'm sure that this will motivate many other entertaining and enlightening
>>>'clueless programmer stories' (kind of like stupid pet tricks, no?)
>
>Also at Microware, a long time ago, in a galaxy far, far away, someone
>here received a 'bug report' that went something like this:
>
>"I think I've found a bug in your operating system.  When I reboot the
>computer, all my background processes go away."
>
>What do you say to someone like that? :)
>
>-- 
>Adam G.
>adamg@microware.com, or ...!uunet!mcrware!adamg
>The above is not to be construed in any way as the official or unofficial
>statements of Microware, or any Microware employees.


-- 
My company never said any of this... I didn't either.
Richard Armstrong, Software Engineer, Martin Marietta
Email->>>> richard@crowded-house.den.mmc.com <<<<-Email
From: farid@gradient.cis.upenn.edu (Hany Farid)
Newsgroups: comp.lang.c
Subject: travelling salesman
Date: 11 Dec 92 19:02:44 GMT
Organization: /home/farid/.organization


I am looking for code that enumerates the (N-1)!/2 possible paths of
the travelling salesman for a map with N cities.  Any help would be
appreciated.  

Hany Farid

P.S. this is in no way related to any kind of class work.
From: jxh@math.ksu.edu (James C. Hu)
Newsgroups: comp.lang.c
Subject: Re: nr.h
Date: 12 Dec 1992 21:48:27 -0600
Organization: Dept. of Mathematics, Kansas State University
NNTP-Posting-Host: hilbert.math.ksu.edu

devido-antonio@cs.yale.edu (Antonio DeVido) writes:

>greetings,
>I have a copy of the book, but I was wondering if s/o could provide
>me with just the two header files "nr.h" and "nrutil.h" for Press,
>Teukolsky et al. to turn my grey day into a productive one. I used to
>have them, but dont seem to have saved them.
>Thanks,
>Antonio

I posted a few days ago to alt.sources with the entire contents of
Appendix B from Numerical Recipes in C 2nd Edition, which was placed
into the public domain.  The contents of Appendix B consisted of
explanations of their allocation schemes for arrays, and the header
file and source code of the vector and matrix allocation routines,
nrutil.h and nrutil.c.  If you have ftp access, you can get them from
hilbert.math.ksu.edu [129.130.6.1].  Login as anonymous, your email
address as password.  They are in /pub/incoming/nrutil.shar.Z.  I'll
work on finding a more permanent home for them.

nr.h to my understanding is still copyrighted, and cannot be freely
distributed.  You must purchase the source disk from Cambridge
University Press.  Mail me if you want the full bit.
-- 
James C. Hu (jxh@math.ksu.edu), 1804 Denholm Dr., Manhattan, KS 66502
I speak for me, the whole me, and nothing but for me.  So help me me.
From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
Newsgroups: comp.lang.c
Subject: Re: Pointer to Function Question
Date: 16 Dec 92 18:37:37 GMT
Reply-To: volpe@ausable.crd.ge.com
Organization: GE Corporate Research & Development

In article <1000001@hplred.HPL.HP.COM>, curry@hplred.HPL.HP.COM (Bo Curry) writes:
|> I have a pointer-to-function question which is baffling me. Perhaps one
|> of the gurus out there has the answer?
|> 
|> typedef struct {
|> 	void (* displayit)(struct _WINDOW *);
                           ^^^^^^^^^^^^^^^^

If this is the first place where the _WINDOW struct tag appears (i.e. there's
no "struct _WINDOW;" or or other such declaration for it in an outer 
scope), then this declaration of the structure tag has _function_prototype_
scope. Its scope ends at the end of the prototype.

|> } DISPLAYTYPE;
|> 
|> static void ShowMyPanes(struct _WINDOW *);

Same thing here. The tag "_WINDOW" has function prototype scope. It 
declares a new type distinct from any other.

To get them both to refer to the same type, you need to declare the structure
tag in an outer scope. Put a "struct _WINDOW;" before the function 
declarations. 

-- 
==================
Chris Volpe
G.E. Corporate R&D
volpecr@crd.ge.com
Newsgroups: comp.lang.c,comp.lang.c++
From: ctaylor@cs.uiuc.edu (Conrad Taylor)
Subject: Printing out a binary tree...???
Organization: University of Illinois at Urbana-Champaign
Date: Wed, 16 Dec 1992 03:39:49 GMT


  I was wondering, does anyone have or know where I can find C/C++
code that would print out a binary search tree as follows:

        6
      /  \
     5    7
    / \  / \
  4 nil nil 9

?

Thanks in advance to all that reply to this post.

-Conrad

ps: Please e-mail me at either of the following
    taylor1@wse.eecs.uic.edu or ctaylor@silver.lcs.mit.edu.

Newsgroups: comp.lang.c
From: cad28526@uxa.cso.uiuc.edu (Chuck Douglas)
Subject: Re: Peek/Poke in C
Organization: University of Illinois at Urbana
Date: Fri, 18 Dec 1992 13:20:09 GMT

pal@regent.e-technik.tu-muenchen.dbp.de (Peter Loibl) writes:

>ericwebb@blackwlf.gwinnett.com (eric webb) writes:

>>Hi again.. does anyone know how to do equivalent of BASIC's PEEK & POKE
>>statements in C?

>I am sorry for my ignorance, but what are PEEK and POKE doing? If you
>describe their task, then this would be lots of help for all the
>"C-Gurus" here.

PEEK and POKE are used in Applesoft BASIC to look at (PEEK) the contents
of or put (POKE) a value in to a specific memory address.  I really
don't believe that there is anything analogous to it in C.  At least
nothing that would serve the use it does in Applesoft.

>Peter Loibl
>pal@regent.e-technik.tu-muenchen.de
-- 
Chuckers -- a computer operator/programmer/benthic sorter/emaciated aryan.
cad28526@uxa.cso.uiuc.edu	          |"You know I'll give you everything
Novanet:  douglas/o/nova douglas/cerl/nova|I've got for a little peace of mind!"
douglas-cerl OR douglas-o@nova.novanet.org|--"I'm So Tired" by The Beatles
From: cbarber@bbn.com (Chris Barber)
Newsgroups: comp.lang.c
Subject: Re: Question to test general C knowledge
Date: 14 Dec 92 19:55:32 GMT
Organization: BBN Systems and Technology, Inc.

In article <scott.40.724096473@kronos.com> scott@kronos.com (Scott Riegelhaupt-Herzig) writes:
>Or, one of my favorites:
>Name the four NULLs in C.
>
>(They are, of course, NULL character, NULL pointer, NULL string, and null 
>statement.)

IMHO, this is exactly the kind of question one should *not* ask. What
particular benefit would a programmer gain from being able to enumerate
this list of replies?  I think that the most likely person to be able
to answer all four correctly would be someone who was taught the
"four NULLs" in a C course and was able to spit them out from memory.
The last person I would want to hire is the kind of guy who memorizes
definitions and rules without any regard to their rationale. 

Besides, only two of your answers could be called "NULL" without
qualification: 

  '\0'        NUL or null character
  (void *)0   NULL or null pointer
  ""          null string or empty string
  ;           null statement or empty statement

Neither the null string nor the null statement would be known simply by the
single word "null".  Furthermore, many may be perfectly familiar with the
concepts but may know these as the "empty string" and the "empty statement".
What you are measuring here is whether someone learned C from the 
same book that you did, not whether they actually have a deep understanding.

-- 
Christopher Barber
(cbarber@bbn.com)
Newsgroups: comp.lang.c
From: misar@rbg.informatik.th-darmstadt.de (walter misar)
Subject: Re: quick addition using char and shorts....
Date: Fri, 11 Dec 1992 17:39:20 GMT
Organization: TU Darmstadt

In article <1992Dec10.154834.8349@news2.cis.umn.edu>, peschko@barracuda.micro.umn.edu (Edward Peschko) writes:
> hello --
> 
> I am writing an application in which both time AND memory are important....
> (well, memory is more important... I am working on a massively parallel 
> environment in which each processor has only 64K). Hence, as much as possible
> I will be using shorts and characters for calculations..
> 
> 	Is there any way to take advantage of the shorts and characters having
> only 8 and 16 bits respectively to do addition? (C, unfortunately, converts
> them to int types before doing the actual addition.) I was thinking of doing
> a function call, but would not the function call overhead be too much to make 
> this worthwhile?

But if you store the result in chars or shorts, the expanding takes place in
registers only, and don't waste memory. Furthermore most compilers would
detect that to chars are added to form a new char, and omit the expansion when
optimizing is done.
 
> 	Also, I was having trouble doing the bit assignments (to substitute for 
> Boolean) I noticed that the only way one can do this is to put it inside a 
> structure.. However, when I do a sizeof (Boolean) with my newly defined type,
> I get 4 (as in 4 bytes)...

Since the machine doesn't handle single bits, it will store the one bit actually
in a word or longword ( or whatever the 'natural' datasize is on your machine).
But you could pack several booleans.
Either:
typedef struct { unsigned b0  :1;
		  ....
		 unsigned b31 :1;
	       } many_bools;
or:
typedef int manybools;
#define b0 1<<0
....
#define b31 1<<31

and then selecting the bits with &(~bn) and storing them with |bn .

If you want an actual boolean type, a typedef char boolean is perhaps
sufficiently optimized.
 
-- 
Walter Misar
misar@rbhp56.rbg.informatik.th-darmstadt.de
From: throopw@sheol.UUCP (Wayne Throop)
Newsgroups: comp.lang.c
Subject: Re: What is Object Oriented Programming II
Summary: syntactic sugar
Date: 14 Dec 92 05:42:22 GMT

: From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
: Message-ID: <1992Dec9.183237.14637@thunder.mcrcim.mcgill.edu>
: > then what do people want to do with OOP that you can not presently 
: > do in C?
: Nothing, really.  It just makes it (significantly!) easier to do some
: things, like subclassing and data hiding - both of which can be
: implemented in vanilla C, 

One way to look at it is like so:  You can do all the same things with
fortran arithmetic if statements that you can do with for, while, and
do/until loops.  But I'd druther have the latter than the former to try
to deal with.  It's more or less the sort of clerical work computers are
good at.   Similarly with objects.  
--
Wayne Throop  ...!mcnc!dg-rtp!sheol!throopw
Newsgroups: comp.lang.c
From: rcc@zycor.lgc.com (Randal C. Clarke)
Subject: Looking for 640x480x16 drivers for VGA
Originator: rcc@oasis.zycor.lgc.com
Organization: Landmark/Zycor  (Austin TX)
Date: Sat, 12 Dec 1992 20:02:48 GMT



  Hi folks,
    
     To make a long story short, I'd like to either write a 640x480x16 driver
with 4 frame buffers, or better yet; get a hold of the source to one.  While
looking over the borland .bgi files, I noticed that drivers exist for 
640x480x16 with 2 buffers; so it doesn't seem like a far-fetched idea to
be able to create one with 4 buffers as long as the VGA card has enough 
memory.  If anyone knows of where I can aquire this beast, or how I would
go about creating this, please let me know.

    I'm using Borland C/C++ 2.0 

    Thanks,
     Randy
------------------------------------------------------------------------------
Randal C. Clarke                                 Landmark Graphics Corporation
rclarke@zycor.lgc.com                               Programmer/Systems Support
From: rjb12@unix.brighton.ac.uk (Titch)
Newsgroups: comp.lang.c
Subject: Bezier & B-spline
Date: 17 Dec 92 10:27:39 GMT
Organization: University of Brighton, UK

Does anyone know if C sources for bezier / b-spline curve generation are
available out there in ftp land?

Cheers,

Rich.
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Rich Browning (rjb12@bton.unix)   * The Intel Plentium: Ethernet controller  
Department of Computer Science    * or fiendish knitting pattern?          
University of Brighton            * What!? It's a PROCESSOR???            
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Newsgroups: comp.lang.c
Subject: TSR sources : request .
From: rodnay@chen.bgu.ac.il (guy rodnay )
Date: Sun, 13 Dec 1992 15:51:54 GMT
Organization: Ben Gurion University, Beer Sheva, Israel


Hi !
------

I would very much apreciate any help on TSR's and any memory
resident information (sources , if possible ) .


			Thanks in advance ,
				Zac P.
		--
NAME Zac Pickholtz
EMAIL eacu158@menix.bgu.ac.il
Newsgroups: comp.lang.c
From: ethan@earl.scd.ucar.edu (Ethan Alpert)
Subject: Re: Rounding floats to X significant digits
Followup-To: comp.lang.c 
Summary: Your response doesn't work for numbers > 1.0
Keywords: rounding float significant digits
Organization: Scientific Computing Divison/NCAR Boulder, CO
Distribution: usa
Date: Mon, 14 Dec 1992 17:15:33 GMT

In article <stanleyr.724176076@kramden> stanleyr@kramden.nyu.edu (Rick Stanley) writes:
>
>ethan@earl.scd.ucar.edu (Ethan Alpert) writes:
> 
>>of significant digits, decimal places.
>
>
>How about the following, which works well for me.

The following doesn't work for large numbers only numbers with digits after
the decimal point. For example, take the number 1,325,160. If I wan't
to round this to 3 significant digits the answer would be 1,330,000. The
code below would return 1,325,160 which is incorect.

-ethan 

>
>/* -----------------------------------------------------------------------
>FILE: Round.cpp          AUTHOR: Rick Stanley             CREATED: 10/10/91
>DESCRIPTION: Round a double number to n decimal places.  for use in rounding
>off dollar amounts to 2 decimal places for increased accuracy in calculations
>and display.  I can't trust the accuracy of printf() using floats.
>--------------------------------------------------------------------------
>Copyright (C) 1991, Rick Stanley (212) 569-9304  All Rights Reserved
>-------------------------------------------------------------------        */
>#include <stdio.h>
>#include <math.h>
> 
>double round(double value, int precision);
> 
>double round(double value, int precision)
>{
>    double result, power;
>    long ltemp;
>    power = pow(10.0, (double) precision);
>    result = (value * power + .5);
>    ltemp = (long) result;
>    result = ((double) ltemp) / power;
> 
>    return result;
>}
>
>/* Where precision is the number of decimal places to round for,
>   dollars = round(dollars, 2); to round to 2 decimal places.  */
>
>I've seen this reduced to one line of code, but prefer to do it this way.
>I believe this will work using negative precision thus rounding the
>left side of the decimal point.  I have not used it that way.  Test it!
>
>-------------------------------------+-----------------------------------
>Rick Stanley                         | R.S. Consultants  (212) 569-9304
>stanleyr@acf14.nyu.edu               | 
>Information Technologies Institute   |        C++ & C Language
>New York University   NYC, NY  USA   | Programming, Training, Consulting
>-------------------------------------+-----------------------------------
>
>


--
Ethan Alpert  internet: ethan@ncar.ucar.edu | Standard Disclaimer:
Scientific Visualization Group,             | I represent myself only.
Scientific Computing Division               |-------------------------------
National Center for Atmospheric Research, PO BOX 3000, Boulder Co, 80307-3000
Newsgroups: comp.lang.c
From: dschmitz@iastate.edu (Daniel C Schmitz)
Subject: Re: How to test a programmer
Organization: Iowa State University, Ames IA
Date: Thu, 17 Dec 1992 20:08:34 GMT

etljmme@etlxd30.ericsson.se (Jim) writes:


>In article 724521723@pv0321.vincent.iastate.edu, dschmitz@iastate.edu (Daniel C Schmitz) writes:
>> [stuff deleted]
>>  This not only
>>tested my programming skills, but my knowledge of graphics algorithms and
>>my attention to details that the programmer must know but were not provided
>>with the original problem description.  E.g. what is the format of the file,
>>should the coins be centered top to bottom with relation to each other and/or
>>to the screen.  Will the input contain errors and/or more coins than will fit
>>on the screen.  What are the sizes of the coins.

>This is interesting, how did you solve uncertanties like the format of the file?
>The format could be almost anything!  The other problems like the size of the
>coins could, I suppose, be left to aesthetics provided the requirement is 
>satisfied but I can't see how to code for handling the file without prior
>knowledge of the file format.  Or is the point simply that the programmer
>recognises these problems?

Yes, a programmer never (well almost never), gets a full
description of a programming task.  A good programmer must not only be able
to write programs to specifications but to recognize incomplete and ambiguous
specifications.  A few questions can save the progammer a lot of time and
the company a lot of money by avoiding mistakes rather than making the
programmer go back and rewrite his/her code.

Anyway, I asked most of these questions before leaving the interview.
A file format was provided, yes there might be errors, more coins than could
fit on the screen is an error, the coins should have appropriate relative
sizes but the absolute size did not matter.  The rest was left up to me.

Dan Schmitz
dschmitz@iastate.edu

Newsgroups: comp.lang.c
From: dockhorn@probitas.cs.utas.edu.au (Patrick Dockhorn)
Subject: Re: A better mousetrap
Organization: University of Tasmania, Australia.
Date: Sat, 12 Dec 1992 05:07:01 GMT

>Bear with me folks.

>What I'm in the process of writing (or trying to write) is a more efficient
>version of uuencode. I've noted that uuencode seems to cause 'file swelling',
>on an average of 1:1.4 for binary files. (That is to say, a 100k binary
>converts to a 140k ascii file.)

>What I've been busy cobbling together is something that could be more
>efficient. To date, my best efforts yield a pathetic average of 1:1.74 ratio
>for binaries.

uuencode converts 3 'binary bytes' into 4 printable ascii characters:

Byte 0   Byte 1   Byte 2
01234567 01234567 01234567
AAAAAABB BBBBCCCC CCDDDDDD

The bits indicated by 'A' form the first character.
uuencode simply adds a space to this value between
0 and 63 thus resulting in a printable ascii
char.  The procedure continues with B, C and
D.  There's also a special BEGIN-OF-LINE token
to avoid problems with newlines.

uuencode was written to allow binary files to be
sent by services that can't handle but printable
characters, (uuencode uses ASCII 32 - 96). Within
this conditions there's no way to improve it - the
only thing is compression, but this is usually done
as a separate process, i.e. you compress a file and
uuencode it then.  I wrote my own uuencode/decode
once because the standard one failed on an IBM 3090
but this only increased the size of the files created
and I used the same method and just added some more 
control information. 

Thus, IMHO, I don't see a chance for an improvement 
of uuencode.

-patsch

--
The only possible interpretation of any research whatever in the
`social sciences' is: some do, some don't.
                -- Ernest Rutherford


Newsgroups: comp.lang.c