HDTenEightyP/NetNews huggingface dataset:
From: lb00197@Corlac (David Porco)
Subject: What about fast learners?(Was Re: Question to test general C knowledge
Organization: Lockheed
Date: Fri, 11 Dec 92 18:12:03 GMT

I don't really know the answer... But I will pose the question.

What about people who have an affininity for computers & languages?  For
example, I was given the task of re-writing the Netware LOGIN program 
so it would be full screen, menu driven, and would give a nice formatted
login message screen.  I decided that "C" would be my best tool, even 
though I had never written a "C" program before, and the bulk of my 
experience is in IBM mainframe systems programming.  Anyway... I bought
a couple of really good books, and wrote the program in about 2 weeks.

Now I am no "C" guru.  But with the correct tools I think I could 
tackle any task in "C".  But I probably couldn't write anything more
than printf("Hello world \n") from memory.
.
 --------------------------------/^\----------------------------------
 The views expressed are my      | |    We make our own reality.
 own, and could change at any    | |
 moment.                         | |     )))))   )   )  ) ))))
 --------------------------------| |      )   )  )))  ) )  )))
 David V. Porco                  | |      ))))   )  )  )    ))))
 Systems Programmer              | |
 --------------------------------| |----------------------------------
Newsgroups: comp.lang.c
From: saud@seas.gwu.edu (Temporary account (slc 11/19/92))
Subject: Re: pointer assignment problem
Organization: George Washington University
Distribution: usa
Date: Tue, 15 Dec 1992 15:17:36 GMT

> In reference to th epointer assignmnet problem I posted 

Thanks to all who repsonded and those who read and try to repsond

all the responds works fine  

For does who want to know is that when using the malloc to a pointer, the size 
of the pointer is not the correct size rather you need to malloc the size of
the stucture that the pointter is pointing to.



thanks again


Wanes
From: scjones@thor.sdrc.com (Larry Jones)
Newsgroups: comp.lang.c
Subject: Re: Questions about token merging and trigraphs
Date: 18 Dec 92 18:54:08 GMT

> I wrote:
>	const char delims[5][4] = {
>		{ '?', '?', '!', '\0' }, ...

In article <1992Dec18.162011.374@taumet.com>, steve@taumet.com (Steve Clamage) writes:
> Actually, it's easier than that.
> 
> You can replace, for example, "??!" with "?\?!".
> The escaped second question mark breaks up the trigraph.

Yep, you're right.  I was thinking that \? was not well-defined in
K&R C, but I just checked and found that I was mistaken.
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
larry.jones@sdrc.com  or  ...uunet!sdrc!larry.jones
That's one of the remarkable things about life.  It's never so
bad that it can't get worse. -- Calvin
From: asrael@bob.informatik.rwth-aachen.de (Stefan Schoef)
Newsgroups: comp.lang.c
Subject: Source of hashpjw
Date: 14 Dec 92 10:05:50 GMT
Organization: Rechnerbetrieb Informatik - RWTH Aachen
NNTP-Posting-Host: bob.informatik.rwth-aachen.de

I'm searching for a paper in which the function hashpjw by Peter
Weinberger was first mentioned. In the dragon book it is said, that
Weinberger introduced it in his C-Compiler implementation, so probably
a paper which documents this Compiler would be right.

I would prefer it if you would send me answers by email, cause I'm
currently working on my master thesis so I don't have time to read
this group (yes I know: this is not very polite but I really have no
time). If you prefer to post the answer please mail me a hint that you
did so 8-)

Any help is greatly appreciated

Thanx, Stefan


   =========================================================================
   !  Stefan Schoef   !  Tel.: +49 - 241 - 60 39 80                        !
   !  Amyastr.32      !____________________________________________________!
   !  5100 Aachen     !----------------------------------------------------!  
   !  Germany         !  E-Mail: asrael@i1.Informatik.RWTH-Aachen.DE       !
   =========================================================================
From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
Newsgroups: comp.lang.c
Subject: Re: Updated and improved "testing competence" questions
Date: 16 Dec 92 08:58:47 GMT
Organization: McGill Research Centre for Intelligent Machines

In article <1gbstkINNfcp@almaak.usc.edu>, ajayshah@almaak.usc.edu (Ajay Shah) writes:

> Questions for an exam on C (for hiring purposes)

> 3. How do you set up .c and .h files ? What goes into the .h and what
> in the .c ?

This is, IMO, the only one that's actually a reasonable test of
competence at programming in general, as opposed to language details.
(Of course, if the position you're hiring for is language lawyer, the
picky detail questions may be appropriate.)

> 9. What is the difference between 'X' and "X"?
>    - 'X' is just the integer 88.  "X" is a pointer to a scratch space
>      containing 88 followed by 0.

Where did you get 88?  Doesn't everyone know capital X is character
231?  (Only half a :-)

Actually, 'X' is an int whose value is whatever character code the
implementation uses to represent the X character.  This may or may not
be 88, 231, or any other specific value.

Herewith my own suggestion for a question.  Of course, this demands a
fair degree of competence on the part of the interviewer, to evaluate
the response, but the interviewer always has to be competent, or is in
danger of being taken for a ride by a snow job artist.

Q: Give three rules of good programming style, and for each one, an
   example of when it would be good to break it.

					der Mouse

			    mouse@larry.mcrcim.mcgill.edu
Newsgroups: comp.lang.c
From: msb@sq.sq.com (Mark Brader)
Subject: Re: Testing competence of potential hires
Organization: SoftQuad Inc., Toronto, Canada
Date: Sun, 13 Dec 92 00:15:49 GMT

>    void abc(char *cde)
>    {
>       for (; *cde; ++cde) *cde = toupper(*cde);
>       return cde;
>    }
>       What errors will the compiler not find?
>         - he is not checking if cde == NULL

And not checking whether the chars are in range.  For example, on an
implementation with 8-bit chars that are signed and where the macro EOF
is defined as (-1), the following causes undefined behavior even after
the "return" statement is corrected.

	char x[2];
	x[0] = -2;
	x[1] = '\0';
	abc(x);

As with the null pointer check, this could be considered correct if
the specification of abc() excluded such values.

In pre-ANSI C, of course, the argument of toupper() must be additionally
be validated with islower().  One implementation of toupper(c) seen in
pre-ANSI implentations is the simple ((c)-'a'+'A').
-- 
Mark Brader, SoftQuad Inc., Toronto, utzoo!sq!msb, msb@sq.com
	"I'm a little worried about the bug-eater," she said.  "We're embedded
	in bugs, have you noticed?"		-- Niven, "The Integral Trees"

This article is in the public domain.
From: gegu@zurich.spectrospin.ch (Gerry Gucher)
Newsgroups: comp.lang.c
Subject: Re: user input for interactive programs - what's the best way?
Summary: gets considered harmful
Date: 15 Dec 92 10:11:56 GMT
Organization: Spectrospin AG, Fallanden Switzerland

In article <1992Dec11.043700.17849@osuunx.ucc.okstate.edu>, gcouger@olesun.okstate.edu (Gordon Couger) writes:
> >
> >Please don't use gets, it is unreliable.
> >--
> >Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
> >Crusader against gets, scanf, and fscanf.  Don Quixote is my pal.
> 
> I will agree that scanf is dangerous in the hands of users and 
> fscanf is all most totaly lacking IN
> in Zen qualities. But in the last 8 years I can find no problems
> with gets.    (vi also suffers from bad karma.)
> If I am missing a problem would you please educate me.
> Gordon Couger
> AB5Dg   Agriculture Engineering Oklahoma State University
> gcouger@olesun.agen.okstate.edu 405-744-6514 day 744-2794 evenings   


Yes you are missing a problem.

gets() is one of the reasons for the internet worm to 'succeed' and
bog down several thousand machines on the whole world. 

The basic problem is that it does read from the standard input 
without checking for input buffer overflow. While this is *especially*
dangerous for data input routines, it is a very bad practice in
general.

For example in our project there is a law:

* Every routine that accepts a pointer argument and writes more than
* ONE data item to the specified or following adresses, must also 
* accept a size argument for that array and must prevent buffer
* overflow !

As a consequence all functions such as sprintf(), strcpy(), strcat()
gets() etc. are banned from our project. We have our own library of
'safe' routines such as Ssprintf(), Sstrcpy(), ... which must be
used. A global rule like this (even if it is implicitely guaranteed
that strcpy() would work) makes it easy to write tools who verify
that reliability problems like this never occur.

Regards

Gerry


+------------------------------------------------------------------+
| Gerry Gucher                             gegu@spectrospin.ch	   |
| Spectrospin AG,  Industriestr 26,  8117  Faellanden Switzerland  | 
+------------------------------------------------------------------+
| A program that  returns the  wrong | There is nothing wrong with |
| result twice as fast is infinitely | making  mistakes,  but make |
| slower.               - H. Spencer | new ones.           - D.Sim |	
+------------------------------------------------------------------+
From: peter@stycx.hacktic.nl (Author)
Newsgroups: comp.lang.c
Subject: Source for compressor
Date: Sat, 12 Dec 92 09:34:02 PST
Organization: River of Doom. Running through Central Holland

Help!! Is there somebody out there who happens to have source for a 
compression program which allows me to archive directories and create 
self extracting files. Any help would be greatly appreciated, I could set 
off to write the whole thing myself but it has to be part of a project 
which has a deadline which I would not like to exceed. (The boss and so 
on).

Thanks and greetings -Peter

----------------------------------------------------------------------------
Peter@stycx.hacktic.nl (Author)                      Stycx BBS +31 3404 59551
The responsibility for chance...lies within us. We must begin with ourselves, 
teaching ourselves not to close our minds prematurely to the novel, 
the suprising, the seemingly radical.                        -Alvin Toeffler   
     
  
Newsgroups: comp.lang.c
From: dan@cae.prds.cdx.mot.com (Dan Breslau)
Subject: Re: Question to test general C knowledge
Organization: none
Date: Mon, 14 Dec 1992 15:04:01 GMT

volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe) writes:

>You miss the point. One of them will happen first. Does the second
>one constitute a modification? Look at it this way: When the "++" operator
>is evaluated, the machine throws a card up in the air with the words
>"put 3 in i" on it. That's the side effect associated with the "++" operator.
>And since the value of the "++i" subexpression is "3", when the "="
>operator is evaluated, the machine throws up another card in the air with
>the words "put 3 in i" on it. The side effects are applied in the order
>in which they fall. But since both side effects do the same thing, is
>the object really being "modified" again when the second card falls?

No, really, you're missing the point.  The point is that you can't
assume that the compiler will behave rationally just because common sense
says it should.  The compiler will behave rationally _only_ where the
ANSI standard says it should (modulo bugs and/or non-compliance.)

Dan Breslau
dan@codex.com
Newsgroups: comp.lang.c
From: gcouger@olesun.okstate.edu (Gordon Couger)
Subject: Re: Purchasing C
Organization: Oklahoma State University, Stillwater
Date: Thu, 17 Dec 1992 18:51:49 GMT

In article <54.335.uupcb@filebank.cts.com> rick.joseph@filebank.cts.com (Rick Joseph)  writes:
>To: gjkirk@napier.uwaterloo.ca
>
>|I am looking at possibly purchasing a C compiler.
>|I would like something that has a debugger and a
>|decent library, but that does not cost hundreds
>|of dollars.
>
>I've been using Microsoft Quick C for about two years now and I
>really like it - but it may not have everything you're looking

I have used Microsoft C, Borland/Turbo C and Mix C on projects.
I use Turbo C for 95 % of my work. I have used Micorsoft when I 
had to MIX when I need to work in tight enviornments. Here's how
I rate them:    Turbo   Microsoft  MIX
   cost             2           3    1 $29.00
   size            40 mg       40mg  700 k min  2 meg max
   windows support best      poor    none
   tech       "     good      poor    good (can get the guy that wrote day/night
   Productivity      1         2      3

I have worked in C for 10 years and am currently making my living
at it. I don't do windows or C++.

If you are on a limited budget get MIX. If you have the money
the speed and convenience of Borland's user interface is the
only way to go. If I had to use Microsoft I would find another
job.

IMHO
Gordon
Gordon Couger
AB5Dg   Agriculture Engineering Oklahoma State University
gcouger@olesun.agen.okstate.edu 405-744-6514 day 744-2794 evenings   
Newsgroups: comp.lang.c
From: jarmo@ksvltd.fi (Jarmo Raiha)
Subject: Re: How to test a programmer
Organization: KSV Instruments ltd. Helsinki,Finland
Date: Sun, 20 Dec 1992 11:59:17 GMT

robert@isgtec.com (Robert Osborne) writes:

>Jarmo Raiha (jarmo@ksvltd.fi) wrote:

>: I'm also beginning to think that especially programmers with a knowledge of
>: compiler techniques will be lousy programmers. They tend to use
>: too much shortcuts.

>You should watch your generalizations.

Yes , I must keep that in mind. I screwed up.
My comment about programmers with compiler expertise
really wasn't meant to be so rude and general (and insultive, perhaps)
Sorry about that. I don't have enough experience to say such generalizations,
and definitely - I was wrong.

What I was meaning:

I have seen some novice programmers (And I was one of them) whose
coding style was guided by thinking 'what kind of code would the compiler
emit in this case'. Just to optimize the C code.

One of the worst examples:
Use some time to expolore compiler's way to implement case statement.
You know that it propably sometimes uses a set of branches and sometimes
a jump  table. And that a jump table is  used when all case values
are sequential. If you just could twist the case values to suitable ones ...
And throw away the natural ones. This means  that you spend
some (quite much indeed)  time to calculate the cpu cycles taken.
Hoping that you can do that better than the optimizer ?

At this moment you may wonder, if I was that poor programmer.
Unfortunately the answer is yes. Maybe that is why I have a habit
to look for this kind of a bad (IMHO) style.

Jarmo Raiha
From: John.Gibney@f386.n632.z3.fidonet.org (John Gibney)
Newsgroups: comp.lang.c
Subject: Re: Gif file format
Date: Sun, 13 Dec 1992 00:00:10

 -=> Quoting Tim@rcsl.demon.co.uk to All <=-

 Ti> From: tim@rcsl.demon.co.uk (Tim Frost)
 Ti> Organization: Roundhill Computer Systems Limited

 >Can anyone provide details of the GIF89A data file format
 >for me please?  

 Ti> If you get hold of the source for FRACTINT this has code in C to
 Ti> read and write GIF files.

FANX! for your suggestion...  However, I already have a copy
of the source to FRACTINT V15.1... and I'm finding the code
rather *difficult* to follow -- I'm trying to find a GIF file
definition something like:-

        Bytes Name     Description
        ----- -------- ---------------------------
        0-5   Version  Version of GIF, e.g. GIF89a
        6-7   Encode   Encoding scheme
                       1=run length encoding
                       2=Huffman...

              Etc...

so that I can "start from scratch".  I've written my
programs in C, with various "controls" so I can build image
files on VAX/VMS and MS-DOS but I'd ultimately like to use
GIF for the data files so I can use FRACTINT to display the
finished images.


John  :-)

... %SYSTEM-W-TMNYFNGRS, too many fingers on keyboard
___ Blue Wave/QWK v2.10

 * Origin: Eastern Mail Centre [PEP] OZ. +61-3-725-1621 (3:632/386)
Newsgroups: comp.lang.c
From: mjn@pseudo.uucp (Murray Nesbitt)
Subject: Re: definition of strncpy stupid?
Organization: Private system in Toronto, ON
Date: Sat, 12 Dec 1992 10:12:57 GMT
	<1992Dec8.210336.26009@rti.rti.org> <19924@ksr.com>
	<1992Dec10.005706.25200@jpl-devvax.jpl.nasa.gov>


kaleb@jpl-devvax.jpl.nasa.gov (Kaleb Keithley) writes:

> And the beauty of C is that you can add anything you want; it'd be trivial
> to add something like:
>
>     #define strncpy0(s1,s2,n) strncpy (s1,s2,n);s1[n]='\0'
>
> to your application's headers.  It's so trivial in fact that it makes me 
> wonder why this thread has gone on for so long...

If you want to do it correctly, it's not quite so trivial.

Given the behavior of the existing C library string functions, a
programmer could reasonably expect to be able to do things like:

    strncpy0( strings[ i++ ], "Hello world\n", 5 );

or,

    strcat( strncpy0( string, "Hello world\n", 5 ), " world\n" );

but the former results in a serious bug, and the latter a syntax
error.

And, of course, the macro name is a member of the set of reserved
names.

-- 
Murray
From: bs@alice.att.com (Bjarne Stroustrup)
Newsgroups: comp.lang.c
Subject: Re: What is Object Oriented Programming? Is C doomed?
Date: 12 Dec 92 14:16:44 GMT
Article-I.D.: alice.24393
Distribution: usa
Organization: AT&T Bell Laboratories, Murray Hill NJ



hartman@ulogic.UUCP (Richard M. Hartman @ negligable) writes

 > OOP and C++ is NOT a "silver bullet", any more than "structured programming"
 > was.  It is a new tool that gives us the potential for things that were
 > more difficult before, but in and of itself does NOTHING.  That is the
 > job of the software designer.  If it is done poorly, it is done poorly
 > no matter what the language or paradigm.

I'll just add that this is what I and others in the C++ community have been
saying for years. OOP/C++ is a powerful set of concepts/tools, but if applied
``with the brain switched off and hopes of miracles fuled by hype merchants''
there is little reason to believe that the results  will be better than what
would have been obtained if C or any other language had been used in that
state of mind.

 > Never speak in absolutes.  It will always lead to trouble.

:-)
Newsgroups: comp.lang.c
From: wieck@jwminhh.hanse.de (Jan Wieck)
Subject: Re: Peek/Poke in C
Organization: Private Site under Mach386
X-Newsreader: Tin 1.1 PL4
Date: Sat, 19 Dec 1992 00:25:45 GMT


ericwebb@blackwlf.gwinnett.com (eric webb) writes:
: Hi again.. does anyone know how to do equivalent of BASIC's PEEK & POKE 
: statements in C?  My guess is that you need to use a far pointer to the 
: type of data (i.e., char, int, etc.), and then stuff the ptr with the seg 
: & offset.  How does one do this stuffing?  Does anyone know of any other 
: way to do it??  I need to go both ways, esp. POKE.

Try it this way:

    #define uchar unsigned char
    #define ufcp  unsigned char far *
    #define MEM_IO_FUNC_PEEK 0
    #define MEM_IO_FUNC_POKE ~MEM_IO_FUNC_PEEK
    #define peek(seg,off) (mem_io((ufcp)MK_FP(seg,off), MEM_IO_FUNC_PEEK, 0)
    #define poke(seg,off,v) (mem_io((ufcp)MK_FP(seg,off), MEM_IO_FUNC_POKE, v)
    #define ptpeek(ptr) (mem_io((ufcp)ptr, MEM_IO_FUNC_PEEK, 0)
    #define ptpoke(ptr,v) (mem_io((ufcp)ptr, MEM_IO_FUNC_POKE, v)

    static uchar get_one_byte_from_memory(adr)
    ufcp adr;
    {
	return(*adr);
    }

    static uchar put_one_byte_into_memory(adr, value)
    ufcp adr;
    uchar value;
    {
	return(*adr = value);
    }

    uchar (*which_memory_func(flag))()
    {
	return(flag ? put_one_byte_into_memory : get_one_byte_from_memory);
    }

    uchar mem_io(adr, func, val)
    ufcp adr;
    int func;
    uchar val;
    {
	return((*which_memory_func(func))(adr, val));
    }


I know, it's a very hard job (and you clearly see BASIC's superiority
over C). Now you got peek() and poke(), which must be called with
an adress specified by segment and offset. And you got ptpeek() and
ptpoke(), which you can call with any type of pointer.

WARNING:
    This example cannot be compiled under UNIX, VMS, TOS, MAC-OS and
    some other operating systems. But this is not a bug, its a feature!


Until later, Jan

-- 
# Any language keeps its own misunderstandings; #
# why shouldn't programming languages do?       #
#                                               #
#            wieck@jwminhh.hanse.de (Jan Wieck) #
Newsgroups: comp.lang.c
From: thanatos@hyperion.wright.edu (Terry Chlebek)
Subject: Re: Turbo C with built-in assembler??????
Organization: Wright State University
Date: Thu, 17 Dec 1992 04:23:31 GMT

chelf@lunatix.uucp (Chad Helfenberger) writes:

>I seem to have gotten a bad copy of Turbo C++ (v3.0).  On the _box_, it says 
>'built-in assembler' along with the other 'features'.  However, when I try 
>to compile a program with inline asm code (as in #pragma inline), it aborts 
>with 'TASM not found'.  Any insight on this?  If it has a built-in 
>assembler, why would it be trying to call tasm?  

DON'T use the '#pragma inline' (or the -B command line option).  This is
what tells the compiler to call TASM to process the assembly language
stuff.  Just use 'asm {...}' for your assembly stuff and the compiler
will use it's built-in assembler to process it.

>Another question.  The manual that came with it is very sparse, and doesn't 
>list the function call prototypes or *anything*.  All it is, basically, is a 
>guide to use the stupid integrated environment (which is nice as a debugger, 
>but NOT an editor).  I know the online help provides all this, but I'd 
>rather have a book that I can use, WHILE I'm in my favorite editor.  :) 

I just load the resident help utility (THELP).  Then you can get help
from anywhere just by pressing the '5' key on the keypad.

>Thanks for any help!!

>-- 
>Chad Helfenberger
>(chelf@lunatix.uucp) 
-- 
Terry Chlebek
thanatos@hyperion.wright.edu
-- 
Terry Chlebek
thanatos@hyperion.wright.edu
Newsgroups: comp.lang.c