HDTenEightyP/NetNews huggingface dataset:
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c
Subject: Re: Strings and integer sizes
Date: 8 Oct 92 18:28:32 GMT
Organization: negligable

In article <3568@carrousel.and.nl> jos@and.nl (Jos Horsmeier) writes:
:[ someone asked about how strings are stored and ... ]
:
:In article <718167097snx@grendel.demon.co.uk>, jes@grendel.demon.co.uk
:(Jim Segrave) writes:
: 
:| What about:
:| 
:| char zoe[3] = "123";
:| 
:| neither b. nor c. applies here.
:
:|In article <1992Oct7.140844.816@newross.Princeton.EDU> blume@tyrolia.Princeton.EDU (Matthias Blume) replies:
:
:|Right, but this is *not* a string at all!  It's a character array together
:|with an initializer, which *looks* like a string.
:
:In article <1992Oct7.161704.5930@hubcap.clemson.edu> mjs@hubcap.clemson.edu (M. J. Saltzman) replies to that:
:
:|Furthermore, it is an erroneous initializer, since it is longer than 
:|its target array.
:
:Sorry, I have to disagree. In C, a string is no more and no less than
:a _conceptual_ data type, there is no `string' type available in C.
:There is a world wide agreement in the C programming world that a
:string must be represented by a sequence of non-zero-value bytes
:(zero or more of them) and terminated by a '\0' byte. 
:
:The standard mentions a string as: ANSI-C 7.1.1 Definitions of terms:
:
:`A string is contiguous sequence of characters terminated by and
:including the first null character.'
:
:The most convenient way to store a string is a character array. The 
:initializer: char zoe[3] = "123"; does, therefore, _not_ store a 
:conceptual string in the array `zoe', but it _is_ a valid initializer. 
:Have a look at ANSI-C 3.5.7 Initialization:
:
:`An array of character type may be initialized by a character string
:literal, optionally enclosed in braces. Successive characters of the
:character string literal (including the terminating null character
:if there is room or if the array is of unknown size) initialize the
:elements of the array.'
:
:So, I agree that a sequence of bytes '1', '2', '3', without a terminating
:zero-valued byte does _not_ conform to the conceptual string type, but 
:I disagree that char zoe[3] = "123"; would be an erroneous initializer.

It is erroneous. "123" is a character array constant of four characters,
'1', '2', '3', '\0'.  Attempting to inialize an array of [3] with this
is erroneous.   "123" would be a proper initializer for an array of size
[4] or above.

	char zoe[4] = "123";		// good
	char zoe[3] = "123";		// possibly not flagged by compiler,
					// but dangerous.



		-Richard Hartman
		hartman@ulogic.COM

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"186,000 mi/sec.  Not just a good idea, it's the LAW!"

Xref: sparky comp.lang.c:15024 comp.software-eng:3793 comp.sys.mac.programmer:17015
From: markh@csd4.csd.uwm.edu (Mark)
Newsgroups: comp.lang.c,comp.software-eng,comp.sys.mac.programmer
Subject: Re: Productivity of a C programmer ?
Date: 15 Oct 1992 16:17:24 GMT
Organization: Computing Services Division, University of Wisconsin - Milwaukee
NNTP-Posting-Host: 129.89.7.4

In article <2060@snap> paj@uk.co.gec-mrc (Paul Johnson) writes:
>[On project estimation]

In article <qX3DsB2w165w@comtch.spk.wa.us> mhughes@comtch.spk.wa.us (Mark Hughes) writes:
>  The best thing to do is to ask a programmer to evaluate how long it 
>will take a team to write your project, and then add 20% or so...

>I have heard one method proposed semi-seriously: ask a new graduate
>for his estimate, double it, and then switch to the next highest
>units.  So if the graduate says two months, allow four years.

Well, this one is serious.  I look at the size of the equivalent source.  Then
I divide it by the number of people who worked on it, deducting 75% if that
number is less than 1 (machine generated).

Then I deduct another 67% if the source came from Berkeley, or 75% if it was
written as a GNU project, else 50% -- except for machine generated code.

I deduct 90% if I wrote the source, since (i) I'm already familiar enough with
it to make the needed hacks in a short time, and (ii) I'm not about to rewrite
what I wrote before, but am instead more likely to cut and paste in what I need.

Then I translate as follows: 2000 lines is 1 month quarter time.  Add in 2
weeks 1/2 time lead in design time (since everything of substance takes 2
weeks to design well, no matter what it is).

For example, take the source to GNU BC minus the machine generated part (the
YACC and LEX outputs).  Let's say it's around 4000 lines and that only one
person worked on it (which seems plausible on stylistic grounds).  It's a
GNU project, so you're down to 1000 lines.  This is the only applicable
dedection.  

So, that's about 2 weeks 1/4 time to write the program and 2 weeks 1/2 time
to design it -- adding to a total of 60 hours full time work, or $2100
minimum charge, which is not far off from the mark.

As another example, let's say I need to make a major enhancement to the package
I wrote.  I find similar software from the same source (GNU) that's about
6000 lines.  So after applying the deductions to the extra 2000 lines (to
get 500) and taking off 90% of the 1000 lines I already have, I get 600 lines,
which translates to 1.2 weeks quarter time, and 2 weeks half time lead in,
or 52 hours = $1820 minimum charge.

Of course, "small" changes don't get the lead-in added in the estimate, but
that's a different story.

Also, if the whole thing had been done at once, it would have been 1500 lines
source (3 weeks quarter time) + 2 weeks half time lead-in for a total of 70
hours or $2450 minimum charge, compared to the $2100 charge and $1820
enhancement fee.  You save money by specifying the whole system at once. :)
Newsgroups: comp.lang.c
From: psweeney@miavx1.acs.muohio.edu
Newsgroups: comp.lang.c
Subject: Moving to a screen location in ANSI C
Date: 7 Oct 92 14:57:07 GMT
Organization: Miami University Academic Computer Service"

Hello all.

I'm a beginner.  I use ANSI C.

How can I "jump" to a screen location and print something there
without affecting the rest of the screen?  I guess I'm looking
for the equivalent of the LOCATE command in QBasic.

Is this possible?

Any response is welcome.
Peter Sweeney
psweeney@miavx1.acs.muohio.edu
Newsgroups: comp.lang.c
From: bjackson@mentor.cc.purdue.edu (Ben Jackson)
Subject: Re: Lookup table location
Organization: Purdue University Computing Center
Date: Wed, 14 Oct 1992 18:41:18 GMT

In article <1bf19uINNb2t@early-bird.think.com> barmar@think.com (Barry Margolin) writes:
>In article <1166@emoryu1.cc.emory.edu> pdomain@emory.edu (Mike Mitten) writes:
>>Say we have the following function, in its own file:
>>
>>char *dayname(int day)
>>{
>>static char *days[] =
>>     {
>>       "Monday",
>>       [etc]
>>     }
>>     [etc]
>>}
>>
>>Is there going to be any difference between putting the array
>>'days' insided or outside the function?  
>
> [ some good info deleted ]
>
>You can declare the variable with "static const char *days[] = ...", and
>prototype the function "const char *dayname(int day)".  The caller will be
>forced to use a "const char *" variable to hold the result (unless he
>explicitly casts the result to a non-const).
>
>Barry Margolin
>barmar@think.com          {uunet,harvard}!think!barmar

On some machines declaring it as const char *days[] will allow the compiler
to put the text of the array into the code segment, which is read-only.  If
the library user attempts to modify the array's conents, it will seg fault.
(This only applies to smart compilers and machines with MMUs, of course)

\\_//
 o o    Ben Jackson
< ^ >   bjackson@mentor.cc.purdue.edu
 \~/         ...@glia.biostr.washington.edu
  V     "Natural laws have no pity."
From: ren@miles.mps.ohio-state.edu (Liming Ren)
Newsgroups: comp.lang.c
Subject: Question about fread() and fwrite()!
Date: 15 Oct 1992 21:48:15 -0400
Organization: Department of Mathematics, The Ohio State University
Distribution: world
NNTP-Posting-Host: miles.mps.ohio-state.edu

I write a short program to test fread() and fwrite(), I don't get what I want and I can't figure out why. Please help.

I use fwrite to write a struct to a file, then fread it from the file. I don' get
the same object. Can somebody nice to explain the behavior of fread and fwrite?
For example, fwrite writes which member first and in which order.

Another question is: Is the size of a structure  the summation of all the size of its elements? If not, any formula for it beside using sizeof()?

The output from my program is:

0  0  
1  0  
2  0  
3  0  


#include<string.h>
#include<stdio.h>

typedef struct words_record{
  char rw[4][12];
  int tf[4]; 
} wr;

  
FILE *ptr;

main()
{
  int i;
  wr *p, temp, temp2;
  for(i=0; i<4; i++)
    {
      strcpy(temp.rw[i], "hhh");
      temp.tf[i]=i;
    }
  ptr=fopen("data2", "wr");
  fseek(ptr, 0L, 0);
  p=&temp;
  fwrite(p, sizeof(wr), 1, ptr);
  p=&temp2;
  fread(p, sizeof(wr), 1, ptr);
  fclose(ptr);
  for(i=0; i<4; i++)
    {
      printf("%d  %d  %s\n", i, temp2.tf[i], temp2.rw[i]);
    }

}









Xref: sparky comp.lang.c:14879 comp.os.msdos.programmer:9861
From: ccsmh@gdr.bath.ac.uk (Mark Harding)
Newsgroups: comp.lang.c,comp.os.msdos.programmer
Subject: [BIOSCOM] How do I ...
Date: 13 Oct 92 08:05:04 GMT
Organization: Bath University Computing Services, UK

Hi,

I'm using Borland C++ bioscom routine to do some comms stuff. 
Can someone tell me how I change to state of the com port e.g. Set CTS and
RTR etc.

Cheers, Mark.
-- 
+------------------------------------------------------------------------------+
|>  Mark Harding, Most excellent & triumphant programmer. NOT!  0225 826057   <|
+------------------------------------------------------------------------------+
Newsgroups: comp.lang.c
From: ab2r@quads.uchicago.edu (Marshall Abrams)
Subject: Re: gcc (WHERE TO FIND MSDOS GCC)
Summary: barancle.erc.clarkson.edu has the MSDOS version
Keywords: gcc djgpp msdos
Reply-To: ab2r@midway.uchicago.edu
Organization: University of Chicago Computing Organizations
Date: Fri, 9 Oct 1992 04:34:07 GMT

In article <Bvs5AB.F02@news.cso.uiuc.edu> walk@mrcnext.cso.uiuc.edu (Todd Walk) writes:
>Where can I find gcc for both msdos and a sequent balance?

Someone posted this address recently for the MSDOS version:

	barancle.erc.clarkson.edu
	in /pub/msdos/djgpp


Xref: sparky comp.lang.c:14792 comp.software-eng:3706 comp.sys.mac.programmer:16768
From: wrp@pslsrv1.gvl.unisys.com (Bill Pringle)
Newsgroups: comp.lang.c,comp.software-eng,comp.sys.mac.programmer
Subject: Re: Productivity of a C programmer ?
Date: 11 Oct 92 01:26:37 GMT
Organization: Paramax Systems, Ivyland, PA

In article <1992Oct8.184718.12802@midway.uchicago.edu> cjh1@midway.uchicago.edu writes:
>Hello, world.
>
>Could any one show me the light on
>"Average productivity of a C programmer in today's industry in terms of
>number of lines of source code produced per day."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You ask a simple question, but it doesn't have a simple answer.

In order to answer your question, you would have to provide some more detail:

	1) How big of a program is it?
	2) How complicated is it?
	3) How rigid are the requirements?
	4) What type of program?  (Real-time, interractive, computational)
	5) How complex is the program?
	6) What is the level of the programmer(s)?
	7) Will they be working full time on the program?
	8) What type of software environment?
	9) What type of phsical environment (private office, bullpen, etc)?
	10) What type of documentation is required?
	11) Is it a "mission critical" program?  Do lives depend on it?

All these (and more) are factors that must be considered when trying to
make any estimates.  The best way to predict, is to have a good database
on past performance.  If you can say something like "This is similar to
the XXX program, which had a productivity rate of XXX LOC/day", then
you can come close (sort of).

All that aside, look at Boehm & pick some numbers out of the air, that's
what the rest of us do :^)


"Any idiot can write a program.  The hard part is to make it work" - me.

============================================================================
Bill Pringle                      Software Tools
Paramax Corporation               Voice: (215)443-7500 X4023
Internet: wrp@ivy.unisys.com      UUCP: ...!uunet!mimsy!widener!gvls1!wrp%ivy
From: wilson@rhombus.cs.jhu.edu (Dwight Wilson)
Newsgroups: comp.lang.c
Subject: Re: NULLing a pointer and INT 0x1c
Date: 9 Oct 92 02:24:00 GMT
Organization: The Johns Hopkins University CS Department

In article <402@ulogic.UUCP> hartman@ulogic.UUCP (Richard M. Hartman) writes:
>In C++ you can pass by reference now (perhaps ANSI C took this too, but
>I am not certain).

Nope, ANSI C does not add references to the language.

>	func(struct xxx &*p)

This is incorrect.  This would be the syntax for a pointer to
a reference, a concept that doesn't make much sense.  You want:

func(struct xxx *&p)

-Dwight
From: martin@mwtech.UUCP (Martin Weitzel)
Newsgroups: comp.lang.c
Subject: Re: Fast way of counting number of bits =1 in an int.
Keywords: bit operations
Date: 13 Oct 92 17:38:41 GMT
Reply-To: martin@mwtech.UUCP (Martin Weitzel)
Organization: MIKROS Systemware, Darmstadt/W-Germany

Various methods of counting bits were discussed here two years ago.
Try to locate the following message ids in your next Usenet archive:

	<26881@mimsy.umd.edu>
	<26979@mimsy.umd.edu>
	<826@neccan.oz>
	<1990Oct14.183932.14482@zeno.mn.org>
	<1990Oct12.154137.28117@zeno.mn.org>

-- 
Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83
From: wietse@wzv.win.tue.nl (Wietse Venema)
Newsgroups: comp.lang.c
Subject: Re: lint
Date: 6 Oct 92 23:36:22 GMT
Organization: Eindhoven University of Technology, The Netherlands

xu@prim.rose.utoronto.ca (Jiefeng Xu) writes:

>I am new to lint. I don't understand why lint always print out great amount of 
>error or warning messages to some programs which have succeeded in compiler
>(gcc) and executed correctly. The message like "syntax error at or near type 
>word "void" " is really confusing. Can anybody show me how to use lint   
>correctly?

Gcc understands standard C and "old" C.  Could it be that your lint
command understands "old" C only?  In that case, you may have to help
lint a little. ftp.win.tue.nl:/pub/unix/unproto4.shar.Z is the source
to a program that can extend the capabilities of old-style lint to
a large subset of ANSI C.

	Wietse
Newsgroups: comp.lang.c
From: u8111091@cc.nctu.edu.tw ()
Subject: yus21bs12yus2112yuix12bx ipwyx1xb
Organization: National Chiao Tung University
X-Newsreader: TIN [version 1.1 PL6]
Date: Tue, 13 Oct 1992 01:30:54 GMT

I don't know how to use it.
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c
Subject: Re: Strings and integer sizes
Date: 12 Oct 92 21:44:39 GMT
Organization: negligable

Comment:

	Somebody probably made the argument that it was more convenient
	than the proper "= { 'a', 'b', 'c'};" and the committee (perhaps
	due to lack of proper caffiene levels in their blood after their
	Mr. Coffee broke down) bought it.

IMnsHO it is a serious misteak.

		-Richard Hartman
		hartman@ulogic.COM

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Moderation in all things....		         ....especially moderation.

Newsgroups: comp.lang.c
From: amorgan@csd-d-3.Stanford.EDU (Crunchy Frog)
Subject: Re: question about duplicate declarations
Originator: amorgan@csd-d-3.Stanford.EDU
Organization: /usr/lib/news/organizatoin
Date: Fri, 16 Oct 1992 02:49:07 GMT

In article <1992Oct13.211753.15516@phri.nyu.edu> 
  roy@mchip00.med.nyu.edu (Roy Smith) writes:
>
>foo (int x)
>{
>	int x;
>
>	...
>}
>
>What should you expect a compiler to do?  

Exactly what it did.  Compile without error.

>In my case, the second "int x" was
>a mistake; it shouldn't have been there at all.  Apparantly, though, the
>compiler treated it as if it was simply a declaration of a new x inside a
>local block.  Is that the reasonable thing to do?  Should it have issued
>some sort of warning about duplicate declarations?

It doesn't have to.  It might be useful if it did.  Remember: When in
doubt, C will let you blast your own leg off if you tell it you would
like to.

C Frog
Newsgroups: comp.lang.c
From: mark@snark.itc.gu.edu.au (Mark Hessling)
Subject: Re: help needed with curses problem
Keywords: curses help
Organization: ITC, Griffith University, Brisbane, Australia
Date: 12 Oct 92 20:57:23 GMT

eda395j@monu1.cc.monash.edu.au (G.J. Ewing) writes:

>After compiling a program using curses under the att environment the compiler
>reports - undefined:
>          _initscr32
>          _endwin
>          _flushinp
>          etc
>                 listing all of the curses functions I am using. This seems to
>indicate that the compiler is not able to find curses, even though I have 
>included the correct header file <curses.h> and compiled the program as follows:       cc -Xa -lcurses prog.c -o prog
>also tried cc -Xa -lcurses -ltermcap prog.c -o prog
>           cc -Xa -lcurses -ltermlib prog.c -o prog
>           cc -Xa -lcurses -ltermcap -ltermlib prog.c -o prog 
>           various combinations of the above
>   with the same result.

>I have initscr() at the beginning of the executable code and endwin() at the endIf anyone out there has any suggestions I would be most obliged to you.
>                                   Greg Ewing
>                                   Undergraduate computing student
>                                   Monash University, Melbourne, Australia.

>ZZ 

Try putting -lcurses at the END of the line. ie

 cc -Xa prog.c -o prog -lcurses

Cheers, Mark
------------------------------------------------------------------------
Mark Hessling                         Email: mark@snark.itc.gu.edu.au
DBA,ITS                               Phone: +617 875 7691
Griffith University                   Fax:   +617 875 7877
Nathan, Brisbane QLD 4111 Australia   *** PDCurses Maintainer ***
------------------------------------------------------------------------
Newsgroups: comp.lang.c
From: pdh@netcom.com (Phil Howard )
Subject: coding an algorithm for flexible use: include files
Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
Date: Wed, 14 Oct 1992 18:28:01 GMT

Ordinarily the most obvious way to encapsulate an algorithm in C is to
write a C function to do it, describe its calling parameters and provide
that function.  I have written some code to do insertions and deletions
of nodes in a binary with balancing to keep the tree near optimal.  The
problem I run into is that I already have about 3 programs where I could
use this code, but each of them handles its nodes in different ways that
a single C function just could not serve all the different programs.

Typically different application uses of a binary search tree will involve
different kinds of keys, so it will usually be necessary to have different
code to do the key comparisons.  This code needs to be inside the function.
One solution is to pass a function address for a function that will do the
actual comparison.  However I came up with a different approach and I would
like to see what people think about the flexibility of this approach to
generalizing an algorithm in code.

The code is written into a header file, with certain aspects of the code
controlled by macros the programming that uses the header file must define.
For instance for the key comparisons, the programmer is to define two macros.
One will simply do a comparison (or may be undefined if the second macro
alone is sufficient) and the other yields the difference in the keys as a
negative, zero, or positive quantity (much as if strcmp() were called for
string compares).

Other macros the programmer must define are the ways to access the various
members of the node, and things like the value of the dummy root node, the
dummy nil node, and whether or not the dummy nil node is safe for storing
into.

The use of this is to define a few macros, one of which selects what kind
of code to generate (find, insert, delete, destroy).  Then do a #include
of the header file and the pre-processor code in the header will select the
proper code to be compiled.

I don't see this approach as having much use in very many situations, but
it seemed like the most flexible in this one.  The programmer can certainly
generate the code inside function definitions to make use of the methods
as functions elsewhere.

I could post this code when I get it cleaned up if that is desired.
-- 
/***********************************************************************\
| Phil Howard  ---  KA9WGN  ---  pdh@netcom.com   |   "The problem with |
| depending on government is that you cannot depend on it" - Tony Brown |
\***********************************************************************/
Newsgroups: comp.lang.c
From: sweetman@sea.com (Bill Sweetman)
Subject: Borland remote debugger under windows 3.1 on novell net
Organization: Systems Engineering Associates
Date: Thu, 15 Oct 92 00:35:52 GMT

=-=-=
all -

i can't seem to find too much information on the BCW 3.1 TD/TPROF
remote debugger.  i'm trying to use it on a Novell 3.1 network.
I've tried the setup command, and i just can't find any help or 
info running this thing ...

any help is appreciated.

ciao,
-bill
=-=-=
-- 

  INET: sweetman@sea.com           System Engineering Associates  (S.E.A.)
    voice: (619)581-6181 x305      2204 Garnet Ave
     fax: (619)581-6184            Suite #303
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Newsgroups: comp.lang.c
Subject: Re: Realloc failure when downsizing (was Re: Probably a simple realloc() question)
Date: 9 Oct 92 08:38:36 GMT
Organization: University of Helsinki

Richard Hartman wants to discuss further why realloc should or shouldn't
return NULL when it fails to make a block smaller.

1. You cannot change the specification of realloc (until around the year
   2000 or so).  Under the current specification, realloc can fail when
   downsizing, which means that you _have_ to check it (ergo, no savings
   in simpler code with no error checking is possible).

2. If realloc returns NULL when failing to downsize, you may be able to 
   learn useful things from it.  For example, that memory is tight, and
   that the size of the block was not changed (you might want to be able
   to use the memory instead of wasting it).  This information is not
   available if realloc returns the original pointer.

3. Even if you can't think of any reason why a library call might fail,
   you shouldn't assume it can't and won't.  This leads to all too
   familiar problems that stem from "knowing" that there is more input
   and that the input is well-formed, or that writes can't fail.

4. In summary, if realloc returns NULL, you win, if it doesn't, you
   loose.  I still don't see what there is to discuss.

5. Also, from a pure common sense point of view, since realloc may fail
   for other reasons than lack of memory, and since no programmer is
   perfect, realloc just might be signalling an error on your part. 
   (Are you _sure_ that the pointer is valid?)  It is simply good
   engineering to program defensively and to include checks for things
   that "can't happen".

--
Lars.Wirzenius@helsinki.fi  (finger wirzeniu@klaava.helsinki.fi)
From: wchau@acsu.buffalo.edu (Wun-Chun Chau)
Newsgroups: comp.lang.c
Subject: looking for source of null device driver
Date: 14 Oct 92 14:06:15 GMT
Organization: State University of New York at Buffalo/Comp Sci



I am looking for the source of null device driver.
Does someone out here know where it can be found.
Or better yet, email me the source code.

Thanx in advance






-- 
==wun-chun Chau===============================What a crazy world!=============
INTERNET:wchau@eng.buffalo.edu UUCP: ...!{rutgers,uunet}!acsu.buffalo.edu!wchau
INTERNET:wchau@acsu.buffalo.edu  BITNET: wchau%acsu.buffalo.edu@ubvm.bitnet
===============Do you want to die young? If you know what I mean :) ==========