HDTenEightyP/NetNews huggingface dataset:
From: trt@duke.cs.duke.edu (Tom Truscott)
Newsgroups: comp.lang.c
Subject: Re: Most difficult part of learning C?
Date: 27 Aug 92 18:16:31 GMT
Distribution: usa
Organization: IBM RTP

>>I am conducting research for a little project concerning difficulties in
>>learning C and how to improve the teaching of C so as to circumvent these
>>problems.

The biggest difficulty in learning C that I have encountered
is the lack of a hand-holding coding&testing environment.
There exist such environments (e.g. CodeCenter), but they are still rare.
I once taught a course using Pascal rather than C because
the available Berkeley Pascal interpreter ("pix") was
far more error-friendly than the available C compiler ("cc").

A difficulty I have not seen mentioned is in learning how
to use the boolean operators & | ^ ~.  These are not used that much
in other languages, which is probably why some students are bewildered.

Some difficulties can be circumvented by avoiding them entirely.
In my opinion the following can be omitted:
    boolean operators
	when teaching && and || warn of the need to "double"
    goto
	I ignore it entirely unless someone brings it up
    enumerated types
    bit fields
    typedefs
    unions
    pointer arithmetic
	C pointers can be taught as easily as Pascal pointers.
	Just teach the "Pascal subset" (no pointer arithmetic).
	Don't teach them "while (*dst++ = *src++)  ;",
	teach them "for (i = 0; (dst[i] = src[i]) != '\0'; i++)  ;"

I am sure many would disagree with this, I guess it depends on
the purpose of the course.  "You took a course on PL/1
and you still don't know about negative binary scaling factors?!"
Is the purpose of the course to explore every last corner of the C language,
or is it to teach some topic for which C happens to be appropriate?
From: mike@pacsoft.com (Mike Stefanik)
Newsgroups: comp.lang.c
Subject: Re: need with help on curses
Date: 29 Aug 92 21:57:31 GMT
Followup-To: comp.unix.programmer
Organization: Pacific Software Group, Riverside, Ca.

In an article, chen@force.ssd.lmsc.lockheed.com writes:
>I need help with curses.  I am new to UNIX and C. [...]
>I am displaying a menu in a window (win1).  When one of the menu items
>is chosen, another window(win2) is displayed on top of win1 (partially
>overlapping win1) for the user to input data. [...] I have not been able
>to get win2 to disappear [...]

The problem is that curses does not understand the concept of window
layers.  One of the things that you can do is create a "window stack".
Before you create a subwindow, duplicate the current stdscr and push
it on the stack; when you want to remove the subwindow, delete it and
pop the previous stdscr off the stack and use overwrite() to replace the
current stdscr with the old one.  Not memory efficient, but it works.

I've redirected followups to comp.unix.programmer.

-- 
Mike Stefanik  mike@pacsoft.com  ...!uunet!pacsoft!mike
Pacific Software Group, Riverside, CA
From: billb@crpmks.uucp (Bill Bochnik (Info Systems))
Subject: Re: Most difficult part of learning C?
Reply-To: billb@crpmks.UUCP (Bill Bochnik (Info Systems))
Organization: Ciba-Geigy Corporation
Date: Wed, 26 Aug 1992 17:22:16 GMT

In article <9208251159.AA04122@ult4> goldstei@cgi.com ("Morris Goldstein") writes:
>I am conducting research for a little project concerning difficulties in
>learning C and how to improve the teaching of C so as to circumvent these
>problems.
>
>When learning C, what things did you find the most confussing/difficult to
>understand?
>
>        -Morris
>
>(goldstein@cgi.com)

Having learned pascal first, getting used to the different operators for 
assignment and equivalency (:= vs = , = vs ==)


-- 
Bill Bochnik			| It's hard to be a James Bond in an Abbott
Systems Analyst 		|	and Costello world.
Ciba-Geigy Corporation		| Signed and sealed, they deliver oblivion.
philabs!crpmks!billb		| It's worse than that, he's dead Jim.
Newsgroups: comp.lang.c
From: dwiseman@spsd630a.erim.org (Dave Wiseman)
Subject: C vs. FORTRAN
Organization: Environmental Research Institute of Michigan, Ann Arbor, Michigan
Date: 3 Sep 92 16:40:36


Help!

I have a (two) simple programs, one in fortran, and one in C.  I have compiled
them both optimized, and timed the results.  The fortran version takes .1 s
to run, and the C version takes 12.5s to run.  I know (hope) that there is a
simple remedy for this.  The project that I am working on has to do many 
sines and cosines, and I'd prefer to keep the entire program in C, and not
mix the languages.  What can I do to improve the speed of the C version?

	Dave Wiseman
	dwiseman@erim.org

-------------------------------------------------------------------------------
#include <stdio.h>
#include <math.h>

main (argc,argv)
     int argc;
     char **argv;
{
  double angle,delta,the_sin,the_cos;
  int i;
  
  angle = 0.0;
  delta = 0.01;
  
  for (i=0; i<1000000; i++)
  {
    the_sin = sin(angle);
    the_cos = cos(angle);
    angle += delta; 
  }
}
-------------------------------------------------------------------------------
      program test

      real*8 angle,delta,the_sin,the_cos
      integer*4 i

      angle = 0.0
      delta = 0.01

      do I=1,1000000
         the_sin = dsin(angle)
         the_cos = dcos(angle)
         angle = angle + delta
      enddo

      end
-------------------------------------------------------------------------------
--
David Wiseman              dwiseman@erim.org
Environmental Research Institute of Michigan

Newsgroups: comp.lang.c,comp.lang.c++
From: ljcummings@poppy.uwaterloo.ca (A Robotic Medievalist)
Subject: C question(s)
Followup-To: ljcummings@poppy.uwaterloo.ca
Originator: ljcummings@poppy.uwaterloo.ca
Organization: University of Waterloo
Date: Tue, 25 Aug 1992 21:02:57 GMT

I'm in the middle of writing a short 'C' program in BC++ ver 2.0 ...
 
Firstly, let me say that I'm not very good in C ... in fact, I'm pretty
terrible.
 
However, I'm here to ask advice so here goes...
 
What I'm trying to do is write a small flashcard program... nothing
fancy... not necessarily any neat graphics or anything like that.
(will add those later perhaps.)
 
but what I want to do is fairly simple, I want to have a data file which is
organised thus:
 
some words of entry one | some words of entry one-B
some words of entry two and | some words of entry two-B
etc. etc.

And to be able to read in either entry one or entry one-B 
(the whole line up to the seperator (|))  display it on the screen,
and wait for a keypress (using getch()) and then display the opposite.
 
	I was thinking the best way to do this was (pardon psuedo-code),

while getch(var) != "|"
	putch(var)
getch()
while getch(var) != "\n"
putch(var)
or something like that.

	(again just psuedo code) ... however this only does  it in one
	way, not both ways... how could I set it up to (randomly from
	the list) choose entry n, then give it's opposite (or answer..)
	and is there a way to make this then keep track of which ones it
	has randomly chosen, so that it doesn't repeat any until the whole
	file has been processed?
 
ANY help would be apprieciated...
 
I don't read these (note cross-posting) newsgroups,  so *please* reply to:
ljcummings@poppy.uwaterloo.ca
Newsgroups: comp.lang.c
From: rankin@eql.caltech.edu (Pat Rankin)
Subject: Re: printf question
News-Software: VAX/VMS VNEWS 1.41    
Organization: California Institute of Technology
Date: Wed, 2 Sep 1992 04:24:00 GMT

In article <3361@dozo.and.nl>, jos@and.nl (Jos Horsmeier) writes...
[ quoting other articles ]
>||   #define HDPI "4" /* Hex Digits Per Int */
>||	   printf( "%0" HDPI "x\n", address );
[ text deleted ]
> in this case, the pre-processor concatenates the constant strings after
> macro replacement.

     Minor quibble:  string concatentation is performed by the compiler,
not the preprocessor.  Since this won't work with pre-ANSI compilers, its
use tends to reduce portability anyway.

		Pat Rankin, rankin@eql.caltech.edu
Newsgroups: comp.lang.c
From: joet@dcatlas.dot.gov (Joe Trott)
Subject: Re: How to fprintf two columns?
Organization: U.S Dept. of Transportation
Date: Fri, 28 Aug 1992 15:38:57 GMT

KSZ@VM.NRC.CA writes:

>I need the following output to a file:
>                    1.2     2.3
>                    1.3     2.4
>                    1.4     2.5
>                      ....
>which contains two columns. They are not generated at the same time, i.e.
>at the first the first column is generated and then write to a file. then
>the file is rewinded and the second column is generated. Now I need write
>the second column to that particular place, say begin with 10th column.
>I have tried fseek() but it  seems to me not working. (?)
> 
>I have spent all day long and still don't see the light. Anybody can help me?

If I were doing it (and I realize I'm not, so your method may differ), I 
would do it by making the first file a scratch file.  Write the first column
to it, rewind it, read it sequentially, write that value plus your second
column value into the *real* output file, then delete the scratch file.

-JTT
From: mjn@pseudo.uucp (Murray Nesbitt)
Newsgroups: comp.lang.c
Subject: Re: main()
Date: 4 Sep 92 09:01:49 GMT
Organization: Private system in Toronto, ON


wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:

>cee1@ra.msstate.edu (Charles Evans) writes:
>>BC++ books say int main(void) but what is the benefit of 'return 0' at the
>>end.. seems like wasted space.
>
>It it NOT wasted space.  Each and every function (that returns at all)
>needs to explicitly return some value, otherwise it will return garbage
>value and cause your hair turn into worms.

Functions do not have to explicitly return values.  What's the return
value of ``free()''?  Of ``srand()''?  Of ``rewind()''?  Are you
telling me I must rewrite my ``void spinthewheel( wheel *w )''
function?

>                                              And if you return random
>values from main, the operating system (that called main to run your
>program) is going to be very confused.

No operating system I have ever encountered will get confused by a
program that returns an arbitrary value.  See if you can confuse your
operating system with the following:

#include <stdlib.h>
#include <time.h>

int main( void )
{
    srand( (unsigned)time( (time_t *)NULL ) );
    return rand();
}

>Of course, if you terminate your program with exit or abort, it will
>never get to the end of main, so in that case there is no need to
>include a return statement there.

Personally, I put a ``return'' statement in regardless, with a 
``/* NOTREACHED */'' if appropriate.

>                                     In fact, as a stylistic issue, I
>prefer to use ``exit(0)'' instead of ``return 0'' in my programs.  That
>is purely personal opinion, of course.

You should be using ``exit( EXIT_FAILURE )'' or ``exit( EXIT_SUCCESS )''.
What does exit(0) mean to VMS?

>C books that have ``void main'' are broken and are probably only useful
>for heating purposes. 

I hope this doesn't include my copy of K&R, in which most example
programs have no explicit return value from main().  This is
functionally equivalent to ``void main()''.

>>so what should i use
>
>Use:	int main(void)
>
>I have ignored the possibility to use command line arguments to main. 
>If you want those, you use the declaration:
>
>	int main(int argc, char **argv)

This much I can agree with.

-- 
Murray
Newsgroups: comp.lang.c
From: rmills@controls.ccd.harris.com (Richard C. Mills)
Subject: C Spell Checker
Organization: Harris Controls
Date: Tue, 1 Sep 1992 20:07:21 GMT

   Anyone out there know where I can get a hold of a C Spell Checker?
I need one to check against standards and such.  Please e-mail if
you have any info on this.

			Thanks,

			Richard Mills

rmills@ccd.harris.com
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: Why should POINTERS be so damn hard to understand ?
Date: 27 Aug 92 15:15:45 GMT
Organization: AND Software BV Rotterdam

In article <25233@castle.ed.ac.uk> chas@castle.ed.ac.uk (C Spencer) writes:
|
|Why does a pointer need to know what it's pointing to? Surely it's just
|an address - if there was only one kind of pointer, there wouldn't be so
|much to learn, and be confused by.

But then we're forced to use explicit casts on _every_ pointer operation,
there's no way then for the compiler to find out what code to generate
for things like p->element, p++, *p etc. etc.

BTW pointers know next to nothing, they're just integral values, but for
us regular folks, they're integral values (or `address values, if you like)
with type information attached to it and so they are for the compiler. 

What you're describing resembles the semantics of pointers in BCPL.
But BCPL knew of just one data type: the machine word. Life was easy
in these days, as long as you didn't need several different types ...

kind regards,

Jos aka jos@and.nl
Newsgroups: comp.lang.c
From: mitchell@mdd.comm.mot.com (Bill Mitchell)
Subject: errno  (was Re: Too many open files)
Bcc:  mitchell
Reply-To: mitchell@mdd.comm.mot.com (Bill Mitchell)
Organization: Motorola, Mobile Data Division - Seattle, WA
Date: Thu, 27 Aug 1992 14:22:24 GMT

in comp.lang.c, wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) said:


>michel@vedge.UUCP (Michel Trudeau) writes:
>> [* fopen fails, some compilers set errno, some don't *]
>
>Yes.  There is no guarantee that fopen set errno to anything at all.
>
>--
>Lars.Wirzenius@helsinki.fi

That's the bottom line, but a bit terse.  Let me expand a bit, reading
from PJP's book The Standard C Library:

Page 50, Using <errno.h> starts out:

"The C Standard leaves much unsaid about the errors that can be reported.
It says even less about the values of any error codes [.....] Even different
versions of UNIX define dirrerent sets of error codes.  If you are writing
code for a specific system you may have to learn its peculiar set of error
codes.  List the header <errno.h> if you can. [...]"

In section 7.1.14, the standard says, "The value of errno is zero at program
startup, but it is never set to zero by any library function.  The value of
errno may be set to nonzero by a library function call whether or not there
is an error, provided the use of errno is not documented in the description
of the function in this International Standard."

Section 7.9.5.3, on the fopen function, does not document the use of errno
by fopen.

So, there is no guarantee that fopen set errno to anything at all, but
it is allowed to set errno to any nonzero value whether or not there
was an error.  See implementation-specific documentation for implementation-
specific details.

-- 
mitchell@mdd.comm.mot.com (Bill Mitchell)

Newsgroups: comp.lang.c,comp.std.c
From: kevin@edscom.demon.co.uk (Kevin Broadey)
Subject: Re: scrcpy implementation question
Organization: EDS-Scicon, Milton Keynes, UK
Distribution: comp
Date: Fri, 28 Aug 1992 18:07:36 GMT

>>>>> In article <PINKAS.92Aug21114508@caraway.intel.com>, "ip" ==
>>>>> pinkas@caraway.intel.com (Israel Pinkas) writes:
ip> Nntp-Posting-Host: caraway


ip> A compiler group working for us has told us that they plan to make the
ip> following optimization for the strcpy library function:

ip> If the sizes of the src and dst are known at compile time (e.g. they are
ip> both declared in the current file as static or auto arrays), and if the
ip> addresses are aligned correctly, then strcpy will be inlined as a partially
ip> unrolled loop of word moves.  In order to avoid checking every byte, they
ip> plan to copy past the terminator ('\0'), and copy a number of bytes equal
ip> to the smaller of the src or dst.

I'm no compiler expert but I'm a seasoned C-hacker, so here's my opinion
after 30 seconds consideration:-

The important point to note is that the clever strcpy code only comes
into play if the *sizes* of src and dst are known at compile-time, in
which case the code simplifies to:-

	memcpy (dst, src, min (sizeof (src), sizeof (dst)))

Furthermore, the clever strcpy is only used when the *alignment* is
favourable, so you're never going to copy outside your reserved memory
area.

This does give different behaviour if the source string overflows dst,
but who in their right mind *intentionally* writes code like that?

--
Kevin Broadey <kbroadey@edscom.demon.co.uk>
EDS-Scicon, Wavendon Tower, Wavendon, Milton Keynes, MK17 8LX, England.
Phone: +44 908 284198 (direct) or +44 908 585858 ext 4198
These opinions are mine: others available on request.
Newsgroups: comp.lang.c
From: stettbac@isibee3 (Juerg Stettbacher)
Subject: C function declaration
Organization: Swiss Federal Institute of Technology (ETH), Zurich, CH
X-Newsreader: Tin 1.1 PL5
Date: Tue, 1 Sep 1992 14:11:07 GMT


How would you call the C function:

   void (*signal(int sig, void(*func)(int)))(int)

And what does this prototype mean?



Thanks for help
Juerg at ETHZ
Newsgroups: comp.lang.c
From: pfeifer@alw.nih.gov (John Pfeifer)
Subject: Re: C function declaration
Organization: National Inst. of Health, DCRT, CSL
Date: Tue, 1 Sep 1992 19:56:24 GMT

In article <1992Sep1.141107.1972@bernina.ethz.ch>, stettbac@isibee3 (Juerg Stettbacher) writes:
|> 
|> How would you call the C function:
|> 
|>    void (*signal(int sig, void(*func)(int)))(int)
|> 
|> And what does this prototype mean?

signal is a function of two arguments
	an integer
	a pointer to a function of one argument
		an integer
	    which returns void
    which retruns
	a pointer to a funcation of one argument
		an integer
  	    which retruns void

Do read chapter 5.12 of K&R.  Rule-o-thumb: * is lower precedence than () or [], so
find the object being declared, read to the right then read to the left observing ()
used for grouping (rather than as functions).

Oh, how would you call it? With the correct arguemnts, of course.  Carefully.

-John
-- 
#include <stdsig.h>

        John Pfeifer                    internet: pfeifer@alw.nih.gov

	"The most creative and holy of men are always quite mad.
	 It is simply a social thing as to wether one is sane or
	 _insane_."				-The Madonna Vampira
Newsgroups: comp.lang.c
From: wgunadi@IASTATE.EDU (Wiwih Gunadi)
Subject: MIDI in C 
Keywords: MIDI
Reply-To: wgunadi@IASTATE.EDU (Wiwih Gunadi)
Organization: Iowa State University
Date: Mon, 31 Aug 1992 00:32:33 GMT

Hi, a few months ago, I saw a a book about writing MIDI-related programs
for DOS machines in C, unfortunately I didn't pay enough attention (@ that time)
to be able to remember its title or author.
If somebody had also known or used this book, please tell me its title and 
where I can get it.

Thanx........
-Wiwih-
From: maven@eskimo.celestial.com (Norman Hamer)
Newsgroups: comp.lang.c
Subject: Novice Questions
Date: 30 Aug 92 00:47:40 GMT
Organization: <<< ESKIMO NORTH (206)-FOR-EVER >>>

I have a couple questions which have been bugging the living <expletive
deleted> out of me.

 Yes, I've read the FAQ...

 1. Given a char array, say char foo[256];, is *foo the same as foo[0]
and is foo+x the same as foo[x] in all implementations?

 2. What's the best way to read in a text configuration file? I've seen
code like this:

 /* Assume open file */

 fgets(line, 80, fd);
 while(!feof(fd))
 {
   /* Muck with the data */
   fgets(line, 80, fd);
 }

 and like this:

 while(fgets(line, 80, fd) != NULL)
 {
   /*Muck with the data */
 }

 and like this:

 while(!feof(fd))
 {
    fgets(line, 80, fd);
    if(feof(fd))
        break;
    /* Muck with the data */
 }

 Which one is best and why? Which is the least likely to provide
erroneous results (the last one if you forget the second feof() will
sometimes leave you with a portion of the last line... not all of it and
not a null string)

 Thanks. Please reply by mail, as I can't read the newsgroup as often as
I wish.
-- 
/* ------------------------------------------------------------ */
/* Norman C. Hamer                                              */
/* maven@eskimo.celestial.com (USENet)                          */
/* The Maven@The Mavenry      (CitNet)                          */
Newsgroups: comp.lang.c
From: msb@sq.sq.com (Mark Brader)
Subject: Re: Passing 2D dynamic array to function
Organization: SoftQuad Inc., Toronto, Canada
Date: Sun, 30 Aug 92 20:45:09 GMT

> I have a 2D array declared as int **array.

No, you have a pointer to pointer to int, which you are using to
implement a 2D array.  A real 2D array would be declared like
this:  int array[98][98];

> How do I pass that to a function?? I've tried :-
>    int func (int **ar, int ...etc.)

Correct, for what you are using.  You then refer to the array elements
in the called function exactly as you would in the caller, e.g. array[x][y]
becomes ar[x][y].
-- 
Mark Brader              | "I think it's safe to say that no person can hope to
SoftQuad Inc., Toronto   |  achieve basic life competence without consulting my
utzoo!sq!msb, msb@sq.com |  work on a regular basis."     -- Cecil Adams

This article is in the public domain.
From: srt@duke.cs.duke.edu (Stephen R. Tate)
Newsgroups: comp.lang.c
Subject: C Compilers
Date: 2 Sep 92 16:33:22 GMT
Organization: Duke University Computer Science Dept.; Durham, N.C.


I thought this would be in the FAQ list, but couldn't find it...

Does anybody have a list of free C compilers?  I'm teaching a C
programming class, and some students are intrigued that the Gnu C
compiler is free...  What I remember (correct me if I'm wrong!) is
that there is a version of Gnu C that generates i386 32-bit native
code, but this is pretty useless for PCs running MS-DOS.  I also
remember a "Small-C" compiler that has been around for years, but
don't remember how useful it is....  So put simply, can someone
explain to me (who has been away from the "PC world" for many years):

(1)  What PC systems the Gnu CC compiler works on?  I assume you
     at least need at 32-bit operating system --- will it work with
     OS/2?

(2)  What other free C compilers are there?  I require the students
     to use ANSI C, but any C compiler will do...  those that are
     asking probably wouldn't mind "ANSI"izing their code before
     uploading it to the UNIX workstations (the "official" class
     computers).

If anybody knows the answers to these questions, please let me know!
E-mail is best, but I will try to keep up with this newsgroup for at
least a few days to read responses.


-- 
Steve Tate srt@cs.duke.edu | The reason why mathematics enjoys special esteem,
Dept. of Computer Science  | above all other sciences, is that its laws are
Duke University     | absolutely certain and indisputable, while those of all
Durham, NC  27706   | other sciences are to some extent debatable. (Einstein)
Newsgroups: comp.lang.c
From: henders@infonode.ingr.com (Greg Henderson)
Subject: Re: Why should POINTERS be so damn hard to understand ?
Organization: Intergraph Corporation, Huntsville, AL.
Date: Thu, 27 Aug 1992 13:59:46 GMT

chas@castle.ed.ac.uk (C Spencer) writes:

>Why does a pointer need to know what it's pointing to? Surely it's just
>an address - if there was only one kind of pointer, there wouldn't be so
>much to learn, and be confused by.

Well one reason that pops to mind is the nice ability to use a pointer 
to traverse an array more efficently than the 'normal' way.  For ex...

You could do this normally:
{
    int a[1000], i; 

    for ( i=0; i<1000; i++ )
	a[i] = get_some_arbitrary_value();
}

Or you could do this w/ a pointer:
{
    int a[1000], *_i;

    for (_i=a;  _i<a+1000; _i++ )
	*_i = get_some_arbitrary_value();
}

These two pieces of code do the exact same thing, but if you are 
worried about low-level efficiency the second version is a little
tighter, as each reference to the array value in the pointer version
requires less work to come up w/ that address.

The second version would not be possible unless you had pointers that
knew what type they were supposed to point to, and thus know how many
bytes to increment the address to get to next guy.
-- 

Greg Henderson   henders@infonode.ingr.com   ...uunet!ingr!infonode!henders


Newsgroups: comp.lang.c