HDTenEightyP/NetNews huggingface dataset:
From: uniteq@netcom.com (Uniteq Application Systems)
Subject: Re: Wanted: program to extract comments from C
Organization: Uniteq Application Systems
Date: Sat, 26 Dec 1992 09:50:28 GMT

In article <1h580nINN11p@life.ai.mit.edu> kenneths@ai.mit.edu (Kenneth J. Schneider) writes:
>well, i just hacked this lex file together:
>

It's OK, but you could also do it with a lot fewer lines (and a much
more complicated engine, but we let lex worry about that stuff):

%%
"//".*				{printf("%s\n", yytext); /* C++ comments */ }
"/*"([^*]|\*+[^*/])*\*+\/	{printf("%s\n", yytext); /* std C comments */ }
.|\n				{ /* ignore everything else */ }

I am uncertain about the correct semantics when mixing the two commenting
styles - the above code allows `//' to comment out a `/*' but not a `*/'.
The code Kenneth presented took the rather strange (IMO) stance of making
either type of comment able to override the other (`//' remains active
within a `/* ... */' pair).

Enjoy,
		- Jeff.
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: Moving from Pascal to C, Help please!!!!!!
Date: 29 Dec 92 10:05:33 GMT
Organization: AND Software BV Rotterdam

In article <8474@charon.cwi.nl> dik@cwi.nl (Dik T. Winter) writes:
|In article <78858@hydra.gatech.EDU> gt6758b@prism.gatech.EDU (Michael Maverick Kopack) writes:

[ Complaints about C: ]
| >                                           I also HATE that there are no true 
| > pass by reference parameters! 

|The second is not a really valid complaint.  The difference between call
|by value and call by reference is specific to Pascal (inherited from Algol
|60), and in fact artificial.  There is no need for such, as C shows with
|its pointer passing, and as Algol 68 did before by 'ref' passing.

If I remember well, the Algol 60 language had no such thing as `call by
reference'. This language implemented the `call by name' parameter passing
mechanism. Though a very subtle difference in many situations, there is
a difference. Have a look at the following snippet of pseudo code:

a[1]= 1; a[2]= 2; i= 1; f(i, a[i]);

f(x, y) { x= x+1; y= y+1; }

The results for a[1], a[2] and i are as follows:

call by value    : a[1]= 1; a[2]= 2; i= 1;
call by reference: a[1]= 2; a[2]= 2; i= 2;
call by name     : a[1]= 1; a[2]= 3; i= 2;

Also, if I remember well, the original implementors had the _intention_ 
to implement the call by reference mechanism, but they simply made a
mistake by implementing the intended reference as a `thunk' of code:
a nameless piece of code that re-evaluated the parameter value when 
needed. It was always fun (in a sadistical manner, that is) to see
people struggle, trying to write a general `swap' routine in Algol 60. ;-)

kind regards,

Jos aka jos@and.nl
From: royd@spider.co.uk (Roy Donaldson)
Newsgroups: comp.lang.c
Subject: Re: C code Layout
Date: 23 Dec 92 11:10:03 GMT
Organization: Spider Systems Limited, Edinburgh, UK.

In article <771@ulogic.UUCP> hartman@ulogic.UUCP (Richard M. Hartman) writes:
>In article <1992Dec18.151710.23851@scott.skidmore.edu> pvonk@scott.skidmore.edu (Pierre VonKaenel) writes:
>>In article <AJ3U.92Dec17172600@onyx.cs.virginia.edu> aj3u@onyx.cs.virginia.edu (Asim Jalis) writes:
>>>I prefer the K&R style of using braces with statement blocks:
>>>

[ Big block of style examples removed ]

I would say that my personal preference is for the style of

        statement
        {
                statement
                statement
                statement
        }

However I have and will code in any of the 2 other bracketing styles
mentioned. For me it comes down to consistency of style than personal
                                   ^^^^^^^^^^^^^^^^^^^^
preference. If I'm modifying code which is written in either of the
other 2 styles, I will follow the style that is already in the module.
This leaves the module with a consistant feel to it and makes it far
mroe readable than if I were to go in and add a different style half-way
through the module.

Roy.


-- 
---                            
J. Roy Donaldson      |  Spider Systems Ltd.  |      Spider Systems Ltd.,
Software Engineer     |    Internetworking    |      Spider Park, Stanwell St.,
royd@spider.co.uk     |        Group          |      Edinburgh, EH6 5NG.
From: dik@cwi.nl (Dik T. Winter)
Newsgroups: comp.lang.c
Subject: Re: Moving from Pascal to C, Help please!!!!!!
Date: 29 Dec 92 03:55:13 GMT
Organization: CWI, Amsterdam

In article <78858@hydra.gatech.EDU> gt6758b@prism.gatech.EDU (Michael Maverick Kopack) writes:
...
 >                                     I co-op with a government research center
 > and they have taught me a little, but I'm having a really big problem 
 > understanding the stuff with pointers.
Now this I do not understand.  I have heard the complaint before.  In what
way is there a difficulty with C pointers when compared to Pascal pointers?
(Except that in C you can use arithmetic, and they are a bit more general.)
 > 
...
 > There are a lot of things about C that I find very frustrating after comming
 > from a decent course in Pascal. For one is the way that Arrays are handled.
 > I like being able to do stuff like    array [6..26] of int whereas in C you
 > get forced into calling the indeces 0-19. I also HATE that there are no true 
 > pass by reference parameters! 
The first is indeed frustrating and is a detriment to numerical mathematics
programming in C; but the same holds for Pascal.  In Pascal all bounds are
fixed by type or declaration.  Try to write in both C and Pascal a general
routine that takes as input a l*m matrix and a m*n matrix and returns a
l*n matrix (either through the parameter list or as a function return).
Here l, m and n are parameters to the routine.  (For bonus points: write
the same such that it performs well on a vector machine.)

The second is not a really valid complaint.  The difference between call
by value and call by reference is specific to Pascal (inherited from Algol
60), and in fact artificial.  There is no need for such, as C shows with
its pointer passing, and as Algol 68 did before by 'ref' passing.
-- 
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland
home: bovenover 215, 1025 jn  amsterdam, nederland; e-mail: dik@cwi.nl
Newsgroups: comp.lang.c
From: mliu@pt.com (Fred Liu)
Subject: Re: Peek/Poke in C
Organization: Performance Technologies, Incorporated
Date: Thu, 24 Dec 1992 14:14:43 GMT

In article <mLF0VB1w165w@wozzle.linet.org> alane@wozzle.linet.org (J. Alan Eldridge) writes:
>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 to access absolute memory addresses under DOS.

There is peek() and poke() available on Sun systems for writing
device drivers.  They are kernel routines and can only be used
by device drivers.  Peek() and poke() are not standard C functions.
However, if you are writing a standalone program, you will be
able to access physical addresses using assignment statements.
Here is an example:  *(char *)0xABCDEF00 = 0xAB; or if your
compiler does not allow this, you could try: (char *)ptr = 0xABCDEF00;
*ptr = 0xAB;

-- 
Fred Liu, Performance Technologies Incorporated		mliu@pt.com
315 Science Parkway, Rochester, New York 14620		uupsi!ptsys1!mliu
Newsgroups: comp.lang.c
From: jutta@opal.cs.tu-berlin.de (Jutta Degener)
Subject: Re: Is this ANSI?
Organization: Techn. University of Berlin, Germany
Date: Sun, 27 Dec 1992 21:10:46 GMT

Welcome to this week's installment of the tag-declaration-with-function-
prototype-scope question.   Our guest tonight, Patrick Draper (draper@ais.org)
knows a compiler that ...

> ... complained about the redeclaration of function foo. If I put the
> structure definition before the prototype, Turbo C++ 1.01 is happy.
[..]
> void foo (struct bar *x);

The tag (structure, union or enumeration type name) `bar' in this
line has function prototype scope.  After the closing ')', the compiler
suffers from complete amnesia regarding `bar's.

> struct bar {
>   int aaa;
>   int bbb;
> };

Thus, this one is a different struct `bar'.

> void foo (struct bar *x)

Because a struct bar is defined in the enclosing scope (between the
declaration and the end of file, that is), this declaration only _uses_
that bar -- it doesn't declare a new one.

> My question is: what does ANSI say about this. Stylistically, I can see that
> it is preferable to define the structure before I use it, however, it is
> defined in the global realm, thus should be visible.

Scopes do not extend backwards.  They start after the declaration (for
things like variable names) or just after the name has been mentioned
(for unions, structs and enumerations), and end with the thing they're
named after (file scope -- end of file,  block scope -- closing '}', etc.)
C is pretty much a one-pass-language in that regard; the compiler doesn't
go back and fix things up for you.

BTW: You don't need to define the structure before you use it, you just have
to declare it.

	struct bar;

	void foo (struct bar *x);

	struct bar {
		... 
	};

	void foo (struct bar * x)
	{
		...
	}

will work fine.

Jutta Degener (jutta@cs.tu-berlin.de)
From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
Newsgroups: comp.lang.c
Subject: Re: floating point arithmetic
Date: 23 Dec 92 17:32:46 GMT
Organization: McGill Research Centre for Intelligent Machines

In article <BznK8A.1xy@magrana1.uucp>, rob@magrana1.uucp (Rob Duncan) writes:

> Has anyone come across code to implement floating point arithmetic
> with C integers?

I did.  I built a PDP-11 assembler, and of course wanted the assembler
to do arithmetic using PDP-11 floats, even if the native floating point
format of the machine it's running on bore no resemblance to the
PDP-11's.  Of course, it doesn't do lots of things IEEE floats do, like
infinities and denormalized numbers and NaNs, 'cause they don't exist
in PDP-11 floats, but it may be useful as a starting point.

It's all up for anonymous ftp from larry.mcrcim.mcgill.edu
(132.206.1.1) in /pdp11.  The directory is a bit messy, because that's
the directory I work in when working with the '11 stuff, but ya pays
yer money and ya takes yer chances.

					der Mouse

			    mouse@larry.mcrcim.mcgill.edu
Newsgroups: comp.lang.c
From: hollasch@kpc.com (Steve Hollasch)
Subject: Re: QUESTION: TRICKS USING THE ? : OPERATOR
Summary: Some comments
Organization: Kubota Pacific Computer, Inc.
Date: Wed, 23 Dec 1992 00:16:17 GMT

dsembr01@orion.spd.louisville.edu (Darren S. Embry) writes:
| 
| Okay, here are a couple of interesting and maybe useful tricks I discovered
| that involve the trinary ? : operator:

| 1)    Using it as a rudimentary if-else statement:
| 
|               (2*3==6)
|                       ? printf ("TRUE")
|                       : printf ("FALSE");
|               
|       as a substitute for
|       
|               if(2*3=6)
|                       printf("TRUE");
|               else
|                       printf("FALSE");

    This would be better written as:

        printf ((2*3==6) ? "TRUE" : "FALSE");

| 2)    Nesting the ? : operator, as in the example below:
| 
|       a?(b?c:d):e             can be written as       a?b?c:d:e
|       a?b:(c?d:e)             can be written as       a?b:c?d:e

    This is pretty ugly.  Here's the style I use for multi-conditionals:

        printf
        (   "Variable type is %s.\n",
            (vartype == VAR_INTEGER) ? "integer"        :
            (vartype == VAR_STRING)  ? "string"         :
            (vartype == VAR_FLOAT)   ? "floating-point" :
            (vartype == VAR_ZLORT)   ? "zlortskatster"  :
            /* Other */                "unknown"        ;
        );


| Now, here are a couple of questions that you must answer:

    Nuh uh.

| I would appreciate lots of answers, and any objections to using this.

    You can also construct monsters like this:

        ((condition) ? function1 : function2) (arg1, arg2, arg3);

    which should be equivalent to:

        if (condition)
            function1 (arg1, arg2, arg3);
        else
            function2 (arg1, arg2, arg3);

______________________________________________________________________________
Steve Hollasch                                   Kubota Pacific Computer, Inc.
hollasch@kpc.com                                 Santa Clara, California
Newsgroups: comp.lang.c
From: masroor@human.ai.kyushu-u.ac.jp (Muhammad Masroor Ali)
Subject: Looking for a debugger
Organization: Dept. of Comp. Sci. and Comm. Eng., Kyushu Univ., Fukuoka, Japan
Date: Sun, 27 Dec 1992 03:08:16 GMT
X-Bytes: 752

Hello all,

I am looking for a source level debugger for the C programs.
Right now I can use dbx or dbxtool, but the later needs an
open window environment, and the former is not that convenient
to use.

Could anybody please let me know about a x window based
source level debugger with convenient user interface (like
dbxtool)?

Thanks in advance,

Masroor
--
     ----------------------------------------------------- 
      Nobody is never too busy to tell you how busy he is.
     _____________________________________________________

     masroor@human.ai.kyushu-u.ac.jp (Muhammad Masroor Ali)
     Department of Computer Science and Communication Engineering
     Faculty of Engineering, Kyushu University
     Fukuoka, 812 JAPAN

    
        
Newsgroups: comp.lang.c
From: brown@NCoast.ORG (Stan Brown)
Subject: Re: argv[] as a general purpose 2D array
Organization: Oak Road Systems, Cleveland Ohio USA
Date: Mon, 21 Dec 1992 11:59:22 GMT

In article <BzKoLn.8BL@mccc.edu> pjh@mccc.edu (P. J. Holsberg) writes:
>Exam question asked that if the name of the file was not typed on the
>command line, the user should be prompted for it.  Most set up a char
>array to hold the name of the file, and strcpy'd to it from argv[1] if
>the name was in argv[1].
>
>One student decided to save some memory space and scanf'd the prompted
>name directly to argv[1]!
>
>Are there any problems to that approach??

Is this a serious question?

Consider the situation where argument 1 is, say, 2 characters long and
the user types in, say, 8 characters in response to the prompt.  If
scanf-ing into argv[1], what do you think will happen?
-- 
Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
Cleveland, Ohio, USA
Newsgroups: comp.lang.c
From: "peter curran" <peter.curran@canrem.com>
Subject: sccs eats good code -
Reply-To: "peter curran" <peter.curran@canrem.com>
Organization: Canada Remote Systems
Distribution: comp
Date: 21 Dec 92 18:51:40 EST

In article <1992Dec18.215413.65833@evolving.com> jww@evolving.com
(John W. Woolley) writes:

>Evolving Systems recently began using a new source control system,
>CMVC, which as I understand it is a wrapper around SCCS.  The new
>source control system interacted with our code in an unintended way.

>We had a chunk of source so:
>  if (strftime(time_str, 64, "%w%H%M%S", time_struct) != 7)
>
>Nice normal ANSI C.  But SCCS had spotted the string %H% in the
>above bit of code, and had done its replacement thing so:
>
>  if (strftime(time_str, 64, "%w12/14/92M%S", time_struct) != 7)
>
>which caused strftime to yield results differing somewhat from those
>intended.

A simple solution is to replace the original string with something
like "%w%\H%\M%\S".  Ugly, but it works.  Unfortunately, it is an
"active" solution - if you don't notice the problem when you write
the code, you may get unexpected replacements, whereas with a "good"
system, you would only get the replacements when you want them.
(As others pointed out, a solution is to get rid of SCCS.  My
recommendation is to get rid of source code management systems,
but that would raise a few screams, so I won't mention it.)

Peter Curran
Usenet: peter.curran@canrem.com     RIME: CRS (#118)
---
  DeLuxe 1.25 #12339  
--
Canada Remote Systems  - Toronto, Ontario
World's Largest PCBOARD System - 416-629-7000/629-7044
From: pegasus@csd4.csd.uwm.edu (David R Hucke)
Newsgroups: comp.lang.c
Subject: Float point format not loaded?
Date: 25 Dec 1992 05:45:18 GMT
Organization: Computing Services Division, University of Wisconsin - Milwaukee
Distribution: world
NNTP-Posting-Host: 129.89.7.4
Originator: pegasus@csd4.csd.uwm.edu

Hi everybody!

I am having a problem with Turbo C 2.0.

I am writing a program that does some float calculations and when I run the
program I get a run-time error saying:  Floating point formats not loaded.
Abnormal termination.

I have included math.h  float.h and even declared a float variable.

The problem appears on a scanf instruction.

Any ideas how to clear up this little problem?


-- 
pegasus@csd4.csd.uwm.edu                David R. Hucke
                                        UW-Milwaukee Film Major
--
From: robohen@ocf.berkeley.edu (Henry Robertson)
Newsgroups: comp.lang.c
Subject: C graphics question
Date: 30 Dec 1992 08:24:09 GMT
Organization: U. C. Berkeley Open Computing Facility
NNTP-Posting-Host: headcrash.berkeley.edu

I just purchased Think C version 5.0 for my Mac Classic II w/ system 7.0
yesterday.  I am learning the language on my own, with a Teach-yourself C
book.  Well, neither the teach-C book nor the manuals that came with ThinkC
describe how to do graphics.  Can someone enlighten me on this via e-mail?


Thanks.

Newsgroups: comp.lang.c
From: kimball@stsci.edu (Timothy Kimball)
Subject: Re: String function names
Organization: Space Telescope Science Institute
X-Newsreader: TIN [version 1.1 PL6]
Date: Thu, 31 Dec 1992 14:20:13 GMT

Ross Smith (alien@acheron.amigans.gen.nz) wrote:
: Out of curiosity, does anyone know the derivation of the names of the more
: obscure string functions? Names like "strcat()" and "strlen()" are obvious
: enough, but what on earth are "strcspn()", "strpbrk()", and "strspn()"
: supposed to mean?
: 
: (I know what the functions *do*, I'm just wondering where the names come
: from.)

You got me.  And if you look on page 388 of Plauger,
_The_C_Standard_Library_, you'll see that he's mystified by it, too-
and he sits on the ANSI standards committees!

tdk
Newsgroups: comp.lang.c
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Another C palindrome puzzle
Organization: Computer Science, University of Melbourne, Australia
Date: Mon, 21 Dec 1992 16:39:38 GMT

manus@evolving.com (Manus Hand) writes:

>fjh@munta.cs.mu.OZ.AU  (Fergus James Henderson) writes:
>>
>>   Next challenge: Write a palindromic "hello world" program in C without
>>   using comments, #if, or #ifdef.  I think it should be possible.
>
>Challenge accepted!
[neat solutions omitted]
>
>Now I suppose I have to come up with the NEXT challenge.  Okaaaayyyy....
>how about a palindromic "Hello world" program, with no comments, #if's,
>#ifdef's, <<<OR #define's!>>>

I liked your idea of using #pragma.
Here's my solution with no comments, #ifs, #ifdefs, or #defines.

	#pragma amgarp#;""\

	main(){char s[]="\
	Hello World"\
	;puts(s);}
	#pragma "=s*rahc"
	char*s="amgarp#};)s(stup;\"dlroW olleH\"=][s rahc{ )(niam\"";
	#pragma amgarp#

Next challenge: (it's starting to get real hard, folks)
	No comments, #ifs, #ifdefs, #defines, and _no #pragmas_.
	I'm not sure if this one is possible.

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
Newsgroups: comp.lang.c
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Subject: Re: FP formats not linked
Organization: University of Helsinki
Date: Thu, 31 Dec 1992 15:58:12 GMT

steve@Celeborn.lvunix.com (Steve Slade) writes:
>Rich Bauer (root@cpp.uucp) wrote:
>: 	  scanf("%lf", &b_avg[i]);
[...]
>because scanf is looking for a long double and you declared it has only a 
>double.

No, scanf is looking for a (pointer to) double.  For scanf, %f is
float, %lf is double, and %Lf is long double.  Further explanations in
any good book about C (checking one before posting about minor
details, or even larger ones, is often a good idea, btw).

--
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: dans@panix.com (Dan Simoes)
Subject: Microsoft/Turbo C libraries
Date: Tue, 22 Dec 1992 20:14:53 GMT
Organization: PANIX Public Access Unix & Internet, NYC

Please excuse if this is the wrong sort of group for this.
I am posting a question for a friend here at work.
Please followup or reply directly to the address in my .sig.
Thanks in advance.

---
>Dan,
>
>Re posting C questions to the Usenet group, the heart of the matter is
>the extent to which objects and libraries produced by compiles from
>different manufacturers are compatible.  Specifically, can I link
>MicroSoft C libraries with Turbo C libraries and objects to yield a
>TurboC executable?
>
>Thanks,
>
>Phil
>
---
Dan Simoes                                       Voice: 914.747.2900 x415
Danix Consulting                                 email: dans@panix.com or
Yorktown Heights, NY                                     dans@danix.uucp
-- 
Dan Simoes                                       Voice: 914.747.2900 x415
Danix Consulting                                 email: dans@panix.com or
Yorktown Heights, NY                                     dans@danix.uucp
Xref: sparky comp.lang.c:18791 comp.programming:3353
From: slahiri@jade.tufts.edu (Sandip Lahiri)
Newsgroups: comp.lang.c,comp.programming
Subject: B-Tree Algos/programs in C needed urgently.
Date: 22 Dec 92 20:11:10 GMT
Organization: Tufts University - Medford, MA


The subject line says it all. Any help/pointers regarding good books/ftp
sites/etc. would be sincerely appreciated. Thanx in advance and have a
merry christmas a great new year.

-Sandip
From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
Newsgroups: comp.lang.c
Subject: Re: What should be returned by the functions...???
Date: 21 Dec 92 17:39:38 GMT
Organization: McGill Research Centre for Intelligent Machines

In article <BzKoIM.L3@cs.uiuc.edu>, ctaylor@cs.uiuc.edu (Conrad Taylor) writes:

> What should the functions, insertright and insertleft, return because
> I'm receiving errors with Borland C++ 3.1.  For exmaple, functions
> isn't returning a value.

[all but control structure removed -dM]
> NODEPTR insertright(NODEPTR p, int x)
> {
>   if (p == NULL) {
>      return;
>      } /* end if */
>   return;
> } /* end insertright */

You declared it as returning NODEPTR but aren't returning anything.
The compiler is quite correct to get upset; if you declare a function
as returning a type, you really need to return a value of that type.
If you don't have mean for it to return anything, then declare it as
returning void.

					der Mouse

			    mouse@larry.mcrcim.mcgill.edu
From: mtoivakk@abo.fi (Martti Toivakka PAP)
Subject: Re: Moving from Pascal to C, Help please!!!!!!
Organization: Abo Akademi University
Date: Wed, 30 Dec 1992 09:15:03 GMT

>In <78858@hydra.gatech.EDU> gt6758b@prism.gatech.EDU (Michael Maverick Kopack) writes:

>>Could somebody please tell me how I should go about trying to learn C? I've
>>gotten SAS/C 6.1, but really don't understand what I'm doing with it. My
>>programming experience has been limited to PASCAL and BASIC and LISP. Heck,
>>they don't even teach C here at GT!  I co-op with a government research center
>>and they have taught me a little, but I'm having a really big problem 
>>understanding the stuff with pointers.


Try Coronado's tutorial on C, available from SIMTEL and its mirrors
in /msdos/c subdirectory:
 
GENCSRC.ARC   122617  8  890114  Coronado's Generic 'C' tutor v2.0, (1 of 2)
GENCTXT.ARC   134648  8  890114  Coronado's Generic 'C' tutor v2.0, (2 of 2)

/martti