HDTenEightyP/NetNews huggingface dataset:
From: zzang@whale.uucp (Zhuo Zang[~{j0WA~}])
Newsgroups: comp.lang.c
Subject: Re: Help! what's wrong with this program?
Date: 6 Sep 92 15:24:42 GMT
Article-I.D.: eng.1992Sep6.152442.25878
Distribution: usa
Organization: University of Florida

In article <1992Sep6.041410.16388@eng.ufl.edu> zzang@whale.uucp (Zhuo Zang[~{j0WA~}]) writes:
>Hello,
>I try to push char c onto buf, and then
>print out the buf.
>But the following codes don't work.
>After compilation, I use
>> foo <foo.c
>nothing printed out.
>
>Could someone tell me why ?
>
>Thanks in advance !
>--------- foo.c ----------
>#include <stdio.h>
>char *sp, buf[BUFSIZ], c;
>main()
>{
>  sp = buf;
>  while ((c=getchar())!=EOF) pushc(c,sp);
some netter remind me that getchar() should return int not char,
so I put casting c=(int)getchar().
and it still doesn't work.
if I dont use ++ in pushc(), and use ++ here, pushc(c,sp++).
the program works just fine. (even without the casting (int)getchar()).
so I doubt this is a pitfall.
>  *sp = '\0';
>
>  puts(buf);
>  return;
>}
>
>pushc(char c, char *bp)
>{
>  *bp++ = c;
>  return;
>}
>-- 
>Zhuo Zang[~{j0WA~}]
>Department of Statistics
>University of Florida            Email: zzang@stat.ufl.edu


-- 
Zhuo Zang[~{j0WA~}]
Department of Statistics
University of Florida            Email: zzang@stat.ufl.edu
Newsgroups: comp.lang.c,comp.lang.c++
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Newsgroups: comp.lang.c
Subject: Re: Problems with QSORT and function prototypes
Date: 15 Sep 92 20:44:01 GMT
Organization: University of Helsinki

pynq@midway.uchicago.edu writes:
>int_cmp(int *p1, int *p2) { return (*p1 - *p2); }
...
>        qsort(things,5,sizeof(struct thing),my_cmp);

The problem here is that the last parameter for qsort (under standard C)
is defined as a pointer to the following kind of function:

	int compare_function(const void *, const void *);

The above function and your int_cmp function are not compatible: there
is no guarantee that the method in which you call one is the same as the
method in which you call the other one.  As a trivial example, a pointer
to an int might be of a different size than a generic pointer (void *).

You have to rewrite your comparison function to be compatible with what
qsort expects.  Like this, for example:

	int int_cmp(const void *p1, const void *p2) {
		int *pi1 = (int *) p1;
		int *pi2 = (int *) p2;
		int i1 = *p1;
		int i2 = *p2;

		if (i1 < i2)
			return -1;
		if (i1 > i2)
			return 1;
		return 0;
	}

You can make the above shorter if you want (I tried to make the above
clear, not efficient).  Please note that it is somewhat dangerous to use
``return i1-i2;'' instead of the if statements, since the subtraction
can overflow (e.g.  if i1 is the smallest negative number, and i2 is
positive).   On some machines integer overflow causes immediate death of
process, and it is an error on all machines, even if it seems to work.

Things `work' if you declare the function using the old style, since in
this case your compiler does not apparently do any argument checking. 
There is not other difference: in one case the compiler does more error
checking, but the generated code should be the same in both cases, and
should thus perform equally badly (if the compiler would output any code
for the first case, that is). 

You might be puzzled why the old style code happens to work (I'm
assuming that it does, and it is probable that it does on your
hardware).  This is yet another case of code working by coincidence. 
The reason is because on your machine all pointers happen to be
identical on the machine code level, the only difference is the type
checking done by the compiler.

--
Lars.Wirzenius@helsinki.fi
Newsgroups: comp.lang.c
Subject: Re: INVERSE CHARACTORS?
From: Pat Cain <patrick@sideways.welly.gen.nz>
Date: Sun, 13 Sep 1992 05:15:50 GMT
Organization: Sideways Bulletin Board, Lower Hutt, New Zealand

slack@hpdmd48.boi.hp.com (David Slack) in <15060003@hpdmd48.boi.hp.com> writes:
> hope this works, neophite notes posting attempt!
> I am trying to learn to program in C, can anyone direct me to where I
> could find out how to print INVERSE charactors?  I am working on a menu
> screen in the HP-UNIX invironment and would like to be able to do it 
> without using curses and in ANSI-C.  Any help is appreciated.

If you are _only_ going to be using the program  from VT100 compatible
terminals (that includes xterm etc.) then here's an easy way:

printf("\x1b[7m");    -- turns inverse on
printf("\x1b[m");     -- turns inverse off

But using curses is a MUCH better idea as the resulting program will
work on virtually any terminal.
From: banshee@natinst.com (Jeff Kellam)
Newsgroups: comp.lang.c
Subject: Re: BeginComment / EndComment
Date: 14 Sep 92 22:13:45 GMT
Organization: National Instruments, Austin, TX
NNTP-Posting-Host: eagle.natinst.com

[Question about commenting out code with comments in it deleted]

At your BeginComment place the following: #if 0
At your EndComment place the following:  #endif

Alternatively, some compilers have a flag to allow nested comments,
check the docs for your compiler to see if this is the case.

Jeff Kellam
From: einari@rhi.hi.is (Einar Indridason)
Newsgroups: comp.lang.c
Subject: Re: primitive Question
Date: 8 Sep 92 17:13:47 GMT

In <1992Sep5.145043.16916@oracle.us.oracle.com> wkaufman@us.oracle.com (William Kaufman) writes:

>In article <1992Sep4.141018.21826@fzi.de> xiong@fzi.de writes:
>] Has someone a "Convert_Integer_to_ASCII" C-function for a C-beginner?

>    I do.  It's a bit long, so I was tempted not to post it, but I think
>it might be of use to the general audience.  Here it is:

>        char int_to_ascii(int i)
>        {
>            return((char)(i & 0x8F));
>        }

>    And the only reason the "& 0x8F" is there is to force (i) into
>0...127; if you can guarantee that it already is in that range, you cast
>drop that.  In fact, you can just drop the function and assign the
>number to the character--even the cast is optional on an ANSI machine.

Sigh.  Here we go again.  Masking out the poor 8th bit.  (btw. it should be
7f, not 8f, if used at all.)

I can tell you one thing:  That program won't be too popular in Europe if
that function is used anywhere near input or output.

What I think the original poster was asking for is something like the atoi
function, but in the other way.

As a solution may I offer this:
           sprintf(buffer,"%d", number);


But don't mask out the 8th bit!

-- 
einari@rhi.hi.is
From: sjs@gnv.ifas.ufl.edu (BORCO)
Newsgroups: comp.lang.c
Subject: Re: C vs. FORTRAN
Date: 8 Sep 92 21:28:05 GMT
Organization: Gormenghast

In article <DWISEMAN.92Sep3164036@spsd630a.erim.org>,
dwiseman@spsd630a.erim.org (Dave Wiseman) writes:

>   int i;
    ^^^

>   for (i=0; i<1000000; i++)
              ^^^^^^^^^

ACK!  Ain't this gonna cause a little problem?  If int on your system
is 2 bytes, i's gonna range from -32,768 to +32,767.  Plus, my PC-Lint
tells me that the constant is out of range for that operator (<).  Mayhaps
the system is off in e-space for 20 some-odd seconds.


----
Bitnet:     sjs@ifasgnv              "Precious and fish are the moments we
Internet:   sjs@gnv.ifas.ufl.edu      two can share."          -- Gollum
From: bbs.ali@tsoft.sf-bay.org (Ali Rahimi)
Newsgroups: comp.lang.c
Subject: Dynamic allocation in fortran
Date: 11 Sep 92 00:02:51 GMT
Organization: The TSoft BBS and Public Access Unix, +1 415 969 8238

Hi everyone.
 
I have a rather large program written in C and FORTRAN (Xwindow interface 
in C, calculations in FORTRAN) and was wondering if there was any way I 
could dynamically allocate an array and use it in my fortran code. I'm 
using Sun's cc and f77. 

By the way, I'm using Sun OS 4.1.

Any help would be greatly appreciated.

--
Ali Rahimi (bbs.ali@tsoft.sf-bay.org)
Xref: sparky comp.lang.c:13627 comp.lang.pascal:5387 comp.lang.misc:3062
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c,comp.lang.pascal,comp.lang.misc
Subject: Re: Opinions on case sensitivity in programming languages?
Date: 14 Sep 92 07:49:55 GMT
Followup-To: comp.lang.misc
Organization: Comp Sci, RMIT, Melbourne, Australia

In article <ART.92Sep11130836@world.std.com>, art@world.std.com (Al Thompson) writes:
> In natural language, spoken or otherwise, case doesn't change the meaning
> of a word.  I am only aware of two such words in the English language,
> polish and Polish and job and Job.  (There's supposed to be a third but
> which it is escapes me at the moment.  Does anybody know?)

There must be dozens of them:  "AIDS" and "aids", "Frank" and "frank",
"Hank" and "hank", ...  Then there are the metric prefixes, in which	
"m" and "M" are distinct, and you'd better not confuse "Nm" with "nm".

-- 
You can lie with statistics ... but not to a statistician.
Newsgroups: comp.lang.c,comp.lang.c++
From: spuler@coral.cs.jcu.edu.au (David Spuler)
Subject: C++ and C efficiency
Organization: James Cook University
Date: 15 Sep 92 05:52:36 GMT


My new book is now available, covering efficiency in the C and C++ languages.
I look forward to hearing any comments you may have about the book.
Further details are below:


Title: "C++ and C efficiency"
Author: David Spuler
Publisher: Prentice Hall, Sydney, 1992
Details:  pp230, 10 chapters
ISBN: 0-13-096595-2


CONTENTS:

1. Introduction
2. Measurement and estimation
3. Algorithm improvements
4. Code transformations
5. C++ Techniques
6. The ANSI C standard library
7. Space-efficiency
8. Abstract data types in C++
9. Example applications
10. Ideas for compiler optimization

--
David Spuler, James Cook University of North Queensland, Australia
Author of "Comprehensive C", Prentice-Hall, 1992, pp416, ISBN  0-13-156514-1
INTRO TOPICS: types, operators, structures, strings, fns, ptrs, files etc etc
ADVANCED TOPICS: efficiency, debugging, style, portability, large programs
From: mjn@pseudo.uucp (Murray Nesbitt)
Newsgroups: comp.lang.c
Subject: Re: main()
Date: 11 Sep 92 07:28:53 GMT
	<1992Sep4.191347.27577@klaava.Helsinki.FI>
	<1992Sep10.003907.15391@sq.sq.com>
Organization: Private system in Toronto, ON


msb@sq.sq.com (Mark Brader) writes:

>| > No operating system I have ever encountered will get confused by a
>| > program that returns an arbitrary value.
>| 
>| VAX/VMS comes to mind: for some exit codes it prints (confusing,
>| erroneous, and misleading) error messages.  For UNIX and MS-DOS, the OS
>| itself doesn't get particularly confused, but the user of the program
>| often does.
>
>Or the calling program; for example, on UNIX make(1) will abort if it
>invokes a program that returns nonzero, unless it's explicitly told
>to ignore the returned status.

Of course programs like ``make'' use the exit value of programs.  The
original poster claimed that the *operating system* would get
"confused" by an arbitrary exit value, which is an entirely different
thing.

>| > You should be using ``exit( EXIT_FAILURE )'' or ``exit( EXIT_SUCCESS )''.
>| 
>| exit(0) and exit(EXIT_SUCCESS) are defined to be exactly equivalent, at
>| least according to Plauger & Brodie's "Standard C" (I do not, alas, have
>| access to a copy of the standard).
>
>Correct according to the standard (section 4.10.4.3 in ANSI numbering,
>7.10.4.3 in ISO).  The choice of 0 or EXIT_SUCCESS is entirely stylistic.

This is true on ANSI conforming systems.  But the real reason for
using EXIT_SUCCESS and EXIT_FAILURE is not Standard-conformance, but
maximal portability.

If the EXIT_SUCCESS and EXIT_FAILURE macros are used, the programmer
needn't worry whether the argument 0 will have this ANSI prescribed
behavior with VMS's (or any other) exit().  I know that the last time
I used a VMS ``cc'', it was not ANSI compliant, but it did define
these two macros.

ANSI implementations define these macros.  Even if a pre-ANSI
implementation lacks them, it is trivial to define them.  This is more
portable than depending on exit() to handle 0 according to the
Standard.

In my opinion, the Standards committee broke exit().  Suppose I am
destitute and morally bankrupt, and decide to program in ANSI C on a
VAX running VMS to make a miserable living.  How do I explicitly
return the value 0 to VMS from my program?  VMS aside, how can I now
be sure I am returning 0 on *any* system?

>Even on VMS, if they now have an ANSI C compiler there.  (It's been years
>since I used VMS.)

You wouldn't have to worry about this issue with the VMS compiler (or
any other C compiler) if EXIT_SUCCESS and EXIT_FAILURE are used.

Why is there a reluctance to use them?

-- 
Murray
From: gordon@osiris.cso.uiuc.edu (John Gordon)
Newsgroups: comp.lang.c
Subject: Re: Command Line Arguments
Date: 9 Sep 92 22:17:31 GMT
Distribution: usa
Organization: University of Illinois at Urbana

drice@ponder.csci.unt.edu (Keith Rice) writes:

>>>	I would like to know how to pass command line arguments in DOS
>>>to a separate function...  I would greatly appreciate if someone
>>>would write an example of a program that passes command line arguments
>>>to a separate function that then prints them on screen.

>>	Was there a specific language you had in mind for this?

>Seeing that he posted to comp.lang.c he obviously must mean C!

	Well, I thought he probably meant C, but you never know.  After
all, it *is* the start of the semester, and a lot of new users are
testing the news.groups waters....

---
John Gordon                        My incredibly witty saying has been 
gordon@osiris.cso.uiuc.edu         Politically Corrected into oblivion.
Newsgroups: comp.lang.c
From: herman@nosc.mil (John W. Herman)
Subject: Re: General data structure and algorithm C source
Organization: Naval Ocean Systems Center, San Diego, CA
Date: Wed, 9 Sep 1992 14:37:10 GMT

wright@epx.cis.umn.edu (Mark Wright) writes:

>In article <1992Sep9.135407.20797@pbhyg.PacBell.COM> jaorans@PacBell.COM (Jeff Oransky) writes:
>>In article <1992Sep9.054305.26077@nuscc.nus.sg> ccewch@nuscc.nus.sg (Wong Chee Heng) writes:
>>>May I know if there is any sample C source that implement data structure
>>>like linked lists, B-tree, sorting, etc. that are published in quite a 
>>>number of books on C. 
>>>
>>>Thanks for any info.
>>>

Stuff deleted

There is a lot of software including code on these and a wide variaty of
other subjects available on simtel20 and mirror sites.  Check the
annotated index for the subject of interest.
Newsgroups: comp.lang.c
From: eletanjm@nuscc.nus.sg (TAN JIN MENG)
Subject: Only C gurus allowed?!?!
Organization: National University of Singapore
Date: Wed, 9 Sep 1992 05:11:07 GMT

I posted something in this group to try to help someone out. 

I got flaming mail to the effect that I was wrong, that my explanation
was garbage etc etc and that I shouldn't post in this group (to help
others) unless I'm very sure of the facts.

Is there some kind of implicit censorship here? To the effect that only
C gurus are allowed to help others here?

Does it matter whether I was right or wrong? There're plenty of fellas
here willing to correct me if I'm wrong .... but please don't be
offensive or [suggest] that I keep quiet.

Is is just this group or what? I don't get this kind of thing in the
other groups I suscribe to. 

I remember the last controversey I stirred up in this group when I titled a 
thread "ANSI C and threads". It was an article about testing a possible
way to write portable threads using C (I did mistitle somewhat) - I got
as many flames (and outright insults) regarding my "misuse of ANSI" as I
did discussing the contents of the article.

I'm fairly pissed.

jin meng
Newsgroups: comp.lang.c
From: sbhatia@mary.fordham.edu (SABU)
Subject: file sharing under DOS (share not necessarily loaded)
Organization: Fordham University
News-Software: VAX/VMS VNEWS 1.41    
Date: Sat, 12 Sep 1992 04:13:00 GMT
X-Posted-From: mary.fordham.edu
X-Posted-Through: sol.ctr.columbia.edu

Hi,

   I have to implement a general purpose moule for file locking uder
dos. I cannot safely assume that share is loaded as we do have 
some users who tinker around with their autoexec.bat and thus
 donot load share. 
   I have successfully implemented a sceheme for VAX/VMS (not using the
lock manager) now I would like to do something like this
for dos but there are problems. The basic problem is say that a user
has three windows open and the same program is running, which accesses
the same dataf file. Two processes request reads and they are successful
that's what I want so it is ok. But the third process comes
in and requests a read operation. Initially I thought that it would
be denied the permission to access the file that is open() would
return a -1 but it doesn't it successfully returns a file handle. Is there
some way that I can test the file control block or something to see
that whether at a certain time some other process is accessing the
file for either a read or a write.

thanks,


sabu

////////////////////////////////////////////////////////////////////////
/   Internet:  SBHATIA@mary.fordham.edu                                /
/   BITnet:    SBHATIA@FORDMULC                                        /
/                                                                      /
/                                                                      /
////////////////////////////////////////////////////////////////////////
Newsgroups: comp.lang.c
From: linema@uni-paderborn.de (Lothar Sander)
Subject: C Asynchron Manager 5.0
Summary: i'm searching the C Asynch Manager 5.0
Keywords: Asynch Manager 5.0, C library
Organization: Uni-GH Paderborn
Date: Tue, 15 Sep 1992 16:24:27 GMT


Hello,

for writing a programm to connect a weather station to an IBM PC
I need the   C Asnch Manager 5.0.
Because a given C code uses some functions from that library.

Please mail me your experience with this package or is there a nother one on the market.

Ciao,  Lothar.
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: How is NaN recognized?
Date: 13 Sep 92 13:54:28 GMT
Organization: AND Software BV Rotterdam

In article <1992Sep8.231535.4925@ecl.psu.edu> y2t@ecl.psu.edu writes:
|A while ago, Gilles_Kohl@spam.fido.de (Gilles Kohl) writes:
|> 
|>another alternative (beside your suggested use of a finite automaton)
|>might be the strtod function from the ANSI standard lib:
|> 
|>double strtod(const char *s, char **enpd)
|> 
|>strtod returns HUGE_VAL in case of overflow, 0 in case of underflow - in both 
|>cases the standard requires errno to be set to ERANGE. What's really nice about 
|>strtod is that it sets the char * pointed to by enpd to where it stopped 
|>converting - makes error detection easier.

|    What about reading floating point values from a binary file? 
|Look at the following codes:
|
|      int    fp;
|      float  x;
|      fp = open(filename, O_RONLY);
|      read(fp, &x, sizeof(float));
|
|    Is there a way to detect if x is a NaN?

I must confess that I'm not a `floating point guru', but I thought that
IEEE <some number> stated that a NaN doesn't compare equal to any number,
including a NaN itself. So `if (x != x) printf("A NaN\n");' could do
the job for you. But I'm not sure what most implementations use when
floating point numbers are concerned ... I stick with the simple bits ;-)

kind regards,

Jos aka jos@and.nl
Date: Sat, 12 Sep 92 15:45:00 +0200
From: Gilles_Kohl@spam.fido.de (Gilles Kohl)
Subject: SEX SEX SEX
Newsgroups: comp.lang.c
X-Comment-To: (William Kaufman)
Organization: To take arms against a C of troubles ... 

 >     No, you've just been slaving in front of the wrong machine.  SEX is
 > the 16-bit-to-32-bit Sign EXtension command.  Why, what did you think it
 > meant?

Bill,

just asked a C++ programmer about it. He thinks it is some private member 
function. Mumbled something about using operator overloading for typesafe 
bindings, too. I don't understand all these new buzzwords, but perhaps they 
mean something to you ;-)

Regards,
Gilles <tongue-in-check> Kohl.

---
Newsgroups: comp.lang.c
From: pdh@netcom.com (Phil Howard )
Subject: dynamic array of structs
Date: Fri, 11 Sep 92 03:06:23 GMT
Organization: Netcom - Online Communication Services  (408 241-9760 guest) 

I am keep one struct, followed by N different structs, together in a
contiguous block of memory.  References to particular ones of the N
structs, to callers of the functions used to interface, is with either
the offset from the beginning of the block or an array index.

If the block is not big enough to hold all the N structs, it is reallocated
and the offsets or indexes remain valid.

My question is what kind of programming style/practice would you recommend?
Email would be prefered unless you feel it is really necessary to say to
everyone (I'll read it either way).

Thanks.
-- 
/***********************************************************************\
| Phil Howard  ---  KA9WGN  ---  pdh@netcom.com   |   "The problem with |
| depending on government is that you cannot depend on it" - Tony Brown |
\***********************************************************************/
From: gonzalod@amex-trs.com (Gonzalo Diethelm)
Newsgroups: comp.lang.c
Subject: yacc and C identifiers
Date: 5 Sep 92 01:34:18 GMT



Distribution: world

Hello everyone,

Two questions about yacc. Assume I'm trying to implement a C compiler:

1. How do you handle identifiers? By this I mean, let's say the
   lexer stores identifiers in the symbol table and returns an ID token
   to the parser, how do I access the identifier from the parser?
   What I'm doing now is having a production

     id : ID
          {
            $$ = yylval;
          }

   where the lexer sets yylval to the position in the symbol table
   the identifier is stored in. This works, but I'm not sure it is
   the correct approach. I know I could define the type of the parser
   stack to be a union and store there the value of the identifier
   (position in symbol table?). Which approach is better? Is there
   another solution superior to any of these?

2. How would you handle name spaces? For example, how could you differentiate
   between the var in

     int   var;

  and the var in

     struct s { int var; };

  or, even better, between all these vars

    struct s1
    {
      int var;
      struct s2
      {
        int var;
        union  u1
        {
          int var;
          float f;
        }
      }
    }

  I CAN think of ways to do this, but somehow I feel the parser itself
  has enough information stored in its states to handle the name spaces.

Any pointers are welcome. Examples are preferred... 8^). Thanks in advance.


gonzalod@amexphx.amex-trs.com
Gonzalo A. Diethelm                 (602)375-8410  home
16220 N 7th St Ap 1314              (602)492-3536  office
Phoenix, AZ 85022                   (602)492-4248  FAX
From: tuan@ukfca1 (Tuan Pham)
Newsgroups: comp.lang.c
Subject: Alternative C compilers under Solaris
Date: 15 Sep 92 15:50:05 GMT
Organization: Schlumberger Technologies, Board Test, Ferndown, England


Hello,
	I am currently looking for a C-compiler for use at our site
	on our Sun workstations under Solaris 2.x (SVR4).

	Our Sun supplier has sent us an 'official' list of approved
	compilers:

	MetaWare High C
	Lucid C
	Sun C
	GCC

	Does any other sites have any experiences with these compilers, or
	know of any others that are suitable ?

	I am particularly looking for info on:

	license fees/prices ( floating, site, bulk ... )
	support from suppliers
	legal issues ( gcc is free, but what about products created from gcc? )
	known problems and features
	compatibility issues
	features : code coverage tools, debugger, optimizations, lint.... etc.

	If you do have any info or contact details, please E-mail me or
	post to this group.  I will summarise and post responses.

	Thanks in advance for your response,
	Tuan Pham

	***************************************************************
	* Tuan L. Pham             | Internet : pham@uk.ate.slb.com   *
	* S/W Eng. Process Group   | SINet    : UKFCA1::PHAM          *
	*--------------------------+----------------------------------*
	* Schlumberger Technologies. Board Test Division.             *
	* Ferndown Industrial Estate, Wimborne, Dorset.  UK.  BH21 7PP*
	* Tel: UK (44) 202 893535    Fax: UK (44) 202 897097          *
	***************************************************************