HDTenEightyP/NetNews huggingface dataset:
From: mikhail@ERE.UMontreal.CA (Mikhail Ossama)
Newsgroups: comp.lang.c
Subject: HELP
Date: 30 Jul 92 15:43:23 GMT
Organization: Universite de Montreal

Bonjour
SVP le programme suivant ne marche pas ..
je sais que vous etes occuper mais SVP essayer de m'aider ..
Merci.
---------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>

main(int argc, char *argv[])
{
if (argc!=4)
 { 
  printf( " Usage : ./link prog.f -o prog.exe \n ");
  exit(0); 
 }
system(f77 argv[1] -o argv[3] -L/usagers/garcia/gqopt/lib -lgq5 -lthomas -p);
}
-----------------------------------------------------------------

Il donne ca :
-----------------------------------------------------------------
accom: Error: link.c, line 11: f77 undefined
       system(f77 argv[1] -o argv[3] -L/usagers/garcia/gqopt/lib -lgq5 -lthomas-p);
       --------------^
accom: Error: link.c, line 11: syntax error
       system(f77 argv[1] -o argv[3] -L/usagers/garcia/gqopt/lib -lgq5 -lthomas-p);
       --------------^
------------------------------------------------------------------
Newsgroups: comp.lang.c
From: bjornmu@idt.unit.no (Bj|rn P. Munch)
Subject: Re: Curious bug...
Organization: Div. of CS & Telematics, Norwegian Institute of Technology
Date: Thu, 23 Jul 92 11:42:02 GMT

In article <1992Jul22.050021.3974@uwm.edu>, pegasus@csd4.csd.uwm.edu (David R Hucke) writes:
|> Hello everybody!
|> 
|> I have a program that I have written in Quick C 2.5 that doesn't work right and
|> I am stumped.

[...]

|> #include <stdio.h>
|> 
|> main()
|> {
|> 
|>    short far *SCREEN = (short far *) 0xB8000000;
|>    short menu[8][20];
|>    short x,y;

[...]

|>    	    fscanf(file,"%c%c",&x,&y);    /* reading in attribute and
|> 					     character bytes */

You have a problem here.  The "%c" conversion will take *one* byte and
store it in the address given, which is the address of your short.

Depending on the "byte sex" of your machine, this may be the high or
low byte (assuming a short is two bytes).  The other byte will contain
garbage, as you haven't given x and y intial values.

What you should do, it to declare x and y as chars, so they will be
set correctly.

|> 	    menu[j][i] = (short)((y<<8)+x);  /* putting together screen

I think you should then move the cast to in front of y:

   	    menu[j][i] = ((short)y<<8)+x;

---
Bj|rn P. Munch               | Dept. of Comp. Science & Telematics,
Bjoern.P.Munch@idt.unit.no   | Norwegian Institute of Technology (NTH),
PhD Student                  | N-7034 Trondheim, Norway
 (some filler words here)    | Fingerable addr:  bjornmu@multe.idt.unit.no
Newsgroups: comp.lang.c
From: welshm@snail.rtp.dg.com (Matt Welsh)
Subject: Re: Error in MS C 6.0 ?
Date: Wed, 22 Jul 92 20:42:54 GMT
Distribution: comp
Organization: Data General Corporation, RTP, NC.

In article <1992Jul21.175215.13891@vax5.cit.cornell.edu> rdw@vax5.cit.cornell.edu writes:
>Dear Microsoft 6.0 C programmers:
>
>     Has anybody noticed a possible error in the Microsoft C 6.0 compiler in
>the way it handles function prototyping?  When passing single-precision float
>arguments to a function, I get compilation errors when I try to use the
>following together:   
>prototyping in the function allusion but 'old-style' argument declarations when
>defining the function.
>
>For example:
>
>extern int func( int a, float x, int b);
>
>with
>The prototyping works fine when I declare the arguments with the new method:
>int func( a, x, b )
>     int a, b;
>     float x;
>{
>
>
>
>int func( int a, float x, int b )
>{
>
>If I use the old method, the compiler gives me a Parameter 2 mismatch error.
>Does anybody know what's going on?

Of course. If you use a prototype, MSC will expect new-style function def's.
You get a Parameter 2 mismatch because MSC thinks that "x" is an integer.


>
>		Baffled,

Aren't we all every now and then. 

>
>		Aaron S. Chou
>		Cornell University


Matt Welsh    welshm@dg-rtp.dg.com        ...!mcnc!rti!dg-rtp!welshm
UNIX-SQA, Data General Corporation RTP        Office: +1 919 248 6070
  "Do not taunt Happy Fun Ball."
From: dave@cs.arizona.edu (Dave Schaumann)
Newsgroups: comp.lang.c
Subject: Re: My view of variable naming conventions (was: Hungarian...)
Date: 27 Jul 92 18:55:11 GMT
Reply-To: dave@cs.arizona.edu (Dave Schaumann)
Organization: University of Arizona

In article <4957@airs.com>, ian@airs (Ian Lance Taylor) writes:
>dave@cs.arizona.edu (Dave Schaumann) writes:
>
>>Absolutely.  There's even a name for this: "encapsulation".  To get more
>>practical: use structs to group related variables, even if makes the actual
>>code a bit longer.  Ultimately, you'll find it makes maintenence easier when
>>related variables are related by a physical structure in the code (as opposed
>>to use and unreliable or nonexistant documentation).
>
>You still have to name the fields of your structure somehow.

True, but the scope of the names in the structure is highly limited:
you can have 10 different structs, all with a field called "foo".
My point is, that in the same way that directories in a file structure
can help you group and seperate your files, structs in a C program
can group and seperate variables.

>>[Difficult-to-remember naming conventions are a poor solution]

>Obviously, nobody would use a naming convention that is difficult to
>remember.

Are you sure?  I haven't studied Hungarian notation, but what I have
seen looked rather non-obvious to me.  Perhaps I am mistaken in my
impression, but I would prefer a convention that was more fundamentally
mnemonic.

>Adopting a (group-wide) naming convention let me go into my own code
>years later and immediately figure out what was going on.

This is what I mean.  Did you know use Hungarian notation, or something
else?

>However, it doesn't do much good to say ``rethink your abstractions''
>when you're dealing with a large amount of code which you don't have
>time to rewrite.

Perhaps so.  But it's certainly worthwhile when you're writing new
code.  My mother has a relevent quote posted on her office door:

  If you don't have time to get it right the first time, how are
  you going to find time to fix it later?

>I'm not at all trying to suggest that everybody should use a naming
>convention

I would.  Any program you write that's over a few hundred lines long,
you're going to spend a lot of time not looking at most of the code.
Even using a simple set of naming conventions can be a great aid to
understanding what you wrote.

Remember: be careful how you choose your names and document your code.
The person who has to come back and maintain it in a year might be you.

-- 
You unlock this door with the key of imagination.  Beyond it is another
dimension: a dimension if sound, a dimension of sight, a dimension of mind.
You're moving into a land of both shadow and substance, of things and ideas.
You've just crossed over into... the Twilight Zone.
Newsgroups: comp.lang.c
From: shulick@navajo.ucs.indiana.edu (Sam Hulick)
Subject: HIgher problems at hand. HELP!
Originator: shulick@navajo
Reply-To: shulick@navajo.ucs.indiana.edu
Organization: Vallen Software
Date: Thu, 23 Jul 1992 23:02:36 GMT


int strstr(char *data, char *chunk)                          
{                                                            
        static int x;                                        
                                                             
        for (x=0;x<strlen(data); ++x)   {                    
                if (!strncmp(chunk, &data[x], strlen(chunk)))
                        return x+1;                          
        }                                                    
        return 0;                                            
}

What's wrong with this subroutine?  I'm making strstr() since Amiga C
doesn't have it.
I do stuff like ..  d  = strstr("foobar", "bar");
and d comes up like 139579275 or some weird value, where it's SUPPOSED to
return either 0 (not found) or some value x, where x is the position in the
string where "bar" starts.  When I say

int strstr(char *data...

Can I pass both *str and str[25]?  For instance..

   char *blah;

   s = strstr(blah....  /* after malloc()'ing it, of course */

  or  char blah[50];  Could either blah be passed into strstr as a (char *)?

Again, reply via email, please.  shulick@indiana.edu
Thanks.

-- 
Sam Hulick  ///  E-mail: shulick@indiana.edu (including NeXT mail)
------------------------------------------------------------------------
  "The pen is the mouth and the paper is the soon-to-be-wise one."
Newsgroups: comp.lang.c
From: twpierce@amhux1.amherst.edu (Tim Pierce)
Subject: Re: Is it MY problem...or is it Borland's?
Organization: Amherst College, Amherst MA
Date: Wed, 29 Jul 1992 21:16:29 GMT

In article <1992Jul27.092039.190@mble.philips.be> stern@mble.philips.be writes:

>This is a bug in your program:
>
>As the string containing the directory is local to function scrollbox,
>it is located on the stack.

This isn't clear at all.  The code for scrollbox was not listed in his
posting, so you can't be sure that the string wasn't malloced, and
hence non-volatile across functions.  In fact, if scrollbox is
Borland-supplied, and the string it returns is a local automatic, this
is a SERIOUS Borland bug.

-- 
____ Tim Pierce                / "You mean there are TWO of you, Pierce?
\  / twpierce@amherst.edu      /  God help us all."
 \/ (BITnet: TWPIERCE@AMHERST) /   -- Major Charles Emerson Winchester III
From: littlec1@jaguar.uofs.edu (Chris Little)
Newsgroups: comp.lang.c
Subject: Good Books on C - question
Date: 22 Jul 92 21:11:57 GMT
Organization: University of Scranton


Hello,

I just started reading this group, so excuse me if I'm raising an issue
already or frequently discussed.  I am interested in a top-5/top-10 list
of books that aid one who is experienced in programming (but not in C)
to learn C.  He has some knowledge of C, so is not a complete novice.  He
expects to use it for rather large and complex applications in the future.

Thanks.

--
Chris Little, Programmer/DBA
                                                University Computing Systems
                                                University of Scranton
  LITTLEC1@JAGUAR.UOFS.EDU                      Scranton, PA 18510
Newsgroups: comp.lang.c
From: overeind@fwi.uva.nl (Benno Overeinder)
Subject: Organization of Prototype Declarations
Organization: FWI, University of Amsterdam
Date: Thu, 30 Jul 1992 09:21:25 GMT

Just new to ANSI C, I wondered whether there is a general accepted way to 
organize the prototype declarations. In particular the place of 'private'
and 'public' prototype declarations in the source files and header files.


Thank U,

Benno
-- 
===========================================================================
 Benno Overeinder			 Computer Systems Department	     
 					 University of Amsterdam	    
 e-mail: overeind@fwi.uva.nl		 The Netherlands
From: smr@iti.org (Stephen Riehm)
Newsgroups: comp.lang.c
Subject: Re: How to implement a bit array?
Date: 27 Jul 92 06:27:21 GMT

ptran@envmsa.eas.asu.edu writes:


>In article <1992Jul17.143744.12549@tamsun.tamu.edu>, 
>tpradeep@cs.tamu.edu (Pradeep K Tapadiya) writes...

>>In my project I need an array of 30000 elements which have {0,1} values only.
>>I guesss a good way to implement this is such that each element takes just
>>one bit. Can someone suggest me a good struct/union implementation for
>>a bit array.
>> 
>>Ideally I should be able to do the following operations:
>> 
>>     whatever.whatever...[13467] = 1; // or 0
>> 
>>     if( whatever.whatever...[i] ) {  code }
>> 
>>However the following is acceptable ( worst case)
>> 
>>   BitSet(Array, 13467, 1);
>> 
>>   if( IsBitSet(Array, i) ) { code }
>> 
>> [etc.]

>     C does not have "bits" available as a type that you can use.  If you
>are not pressed for space (13467 as an index?), use an array of char.  I
>believe that characters are the narrowest type you can have an arrow of.

or you can extend this to an array of chars, and mask use all the bits
in each char, here is a letter I posted to someone last year to solve
this same problem.

--- cut here ---
[nosave]
You should find this reasonably efficient, although not as elegant as
having C do everything for you. I hope you find the right solution!
note that I haven't included any error checking, range checks etc, and
that the code is a bit "rough" but it should do the trick with a bit of
"tweaking".

I have also included a small test routine at the bottom of this mail

--- cut here --- File: bits.c
#define BYTE_SIZE	8

struct matrix_s
{
	int	width;
	int	height;
	char	*matrix;	/* use malloc to create array of appropriate
				 * size ( typically size/8 chars )
				 */
};

set_xy( m, x, y )
struct matrix_s *m;
int		x;
int		y;
{
    long	bitnum;

    bitnum = x * m->width + y;
    m->matrix[ bitnum / BYTE_SIZE ]
	|= ( unsigned char )( 1<<( bitnum % BYTE_SIZE ) );
}

clr_xy( m, x, y )
struct matrix_s *m;
int		x;
int		y;
{
    long	bitnum;

    bitnum = x * m->width + y;
    m->matrix[ bitnum / BYTE_SIZE ]
	&= ~( unsigned char )( 1<<( bitnum % BYTE_SIZE ) );
}

tst_xy( m, x, y )
struct matrix_s *m;
int		x;
int		y;
{
    long	bitnum;
    char	rtn;

    bitnum = x * m->width + y;
    rtn = m->matrix[ bitnum / BYTE_SIZE ]
	& ( unsigned char )( 1<<( bitnum % BYTE_SIZE));
    return( rtn != 0 );
}
--- cut here --- EOF: bits.c

and here is a small test routine I used to make sure that the arithmetic
is correct:

--- cut here --- File: test.c
#include <stdio.h>

main( argc, argv )
int	argc;
char	**argv;
{
    int		x,y;

    if( argc != 3 )
    {
	printf( "for testing: %s x y\n", argv[0] );
	printf( "default grid width.height = 10.10\n" );
	printf( "no error checking\n" );
	exit( 1 );
    }
    x = atoi( argv[1] );
    y = atoi( argv[2] );

    printf( "( %d, %d ) -> bit %d pos %d, bit pattern 0x%-2.2x\n", x, y,
	x * 10 + y, ( x * 10 + y ) / 8,
	( unsigned char )( 1<<( ( x * 10 + y ) % 8 ) ));
}
--- cut here --- EOF: test.c
From: raeker@tc4.fi.ameslab.gov (Todd J. Raeker)
Newsgroups: comp.lang.c
Subject: array element swapping
Date: 30 Jul 92 16:10:48 GMT
Reply-To: raeker@tc4.fi.ameslab.gov (Todd J. Raeker)
Organization: Ames Laboratory

I need to swap values in an array while sorting it, currently I am doing
the swap as follows on floats


            temp = ztmp[j];
            ztmp[j] = ztmp[k];
            ztmp[k] = temp;


This is currently a bottleneck in my program and I need to figure a 
better way to do due this.  Since I am not an advanced c programmer, this
is the best I could come up with, is there a more efficient way?

Thanks

-- 


Dr. Todd J. Raeker           |      307B Wilhelm Hall
raeker@tc4.fi.ameslab.gov    |      Iowa State University
Phone (515)-294-9927         |      Ames Laboratory, USDOE
FAX   (515)-294-5204         |      Ames, Iowa 50011
Newsgroups: comp.lang.c
From: vanroy@prl.dec.com (Peter Van Roy)
Subject: Two 'malloc' questions
Keywords: malloc free
Organization: Digital Equipment Corporation - Paris Research Laboratory
Date: Wed, 29 Jul 1992 09:25:17 GMT

Here are two questions that I urgently need answers to:

1. Is there a public domain version of malloc+free that uses a fixed area
   of memory, which is given it upon initialization?  It should not touch
   the Unix break, but stay within the fixed area.  It should give an
   error if it is not possible to allocate a block in the area.  The
   call to free should do its job, i.e. an infinite sequence of mallocs and
   frees of the same size should work.

2. Is it possible to initialize things so that file operations do not
   call malloc under Ultrix (on a DECstation)?  I know there is a call
   f_prealloc under RISC/os (on a MIPS workstation) that does this.  It does
   not exist under Ultrix as far as I know.  Calling fopen under Ultrix does
   mallocs of various sizes: several 28 and 256 byte blocks, and seven (yes,
   count 'em!) 8192 byte blocks.

These two questions are important for the correct operation of the Aquarius
Prolog system under Ultrix.  Aquarius Prolog does its own memory management.
It has been ported to several machine/OS configurations.

During execution of the backend of Aquarius Prolog under Ultrix, the file
operations call malloc, which interferes with Aquarius' own memory management.
This is how: Aquarius manipulates the  Unix break itself (the top of the bss,
i.e. available dynamically-allocated space) to get more space from Unix when
needed (e.g. when garbage collection does not recover enough memory).  Malloc
allocates memory by getting more space from Unix starting at the break.  In
other words, if Aquarius ever increases the break, then its memory will
overlap with what malloc has allocated before.

Thanks much for any help!

Peter

----------------------------------------------------------------
Peter Van Roy
Digital Equipment Corporation          Net: vanroy@prl.dec.com
Paris Research Laboratory              Tel: [33] (1) 47 14 28 65
85, avenue Victor Hugo                 Fax: [33] (1) 47 14 28 99
92500 RUEIL MALMAISON CEDEX
FRANCE
----------------------------------------------------------------


Newsgroups: comp.lang.c
From: jle9162@venus.tamu.edu (ECKHARDT, JASON LEE)
Subject: fast circle
News-Software: VAX/VMS VNEWS 1.41    
Organization: Texas A&M University, Academic Computing Services
Distribution: usa
Date: Thu, 30 Jul 1992 04:46:00 GMT

  I'm looking for a FAST circle algorithm...'C' code or pseudocode, it
doesn't matter, as long as it cooks.

Thanks, jason.

Xref: sparky comp.lang.c:11602 comp.lang.c++:11553
From: bright@nazgul.UUCP (Walter Bright)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: malloc/new memory allocatio overhead?
Date: 25 Jul 92 17:42:30 GMT
Reply-To: bright@nazgul.UUCP (Walter Bright)
Followup-To: comp.lang.c
Organization: Zortech, Seattle

In article <1992Jul14.132746.23256@ncsu.edu> odkahn@eos.ncsu.edu (Opher D. Kahn) writes:
/Does anybody know exactly what memory allocation overhead results
/from a new or malloc?

With Zortech C/C++, the malloc'd size is rounded up to the nearest 2/4
byte boundary, and then 2/4 bytes are added (for the size). Whether
it is 2 or 4 depends on if it is a 16 or 32 bit program.
From: jfw@ksr.com (John F. Woods)
Newsgroups: comp.lang.c
Subject: Re: Summary: Why use "extern" on function prototypes.
Date: 21 Jul 92 15:58:50 GMT
Article-I.D.: ksr.14004

Since I'm following up a followup, and not sure of the attributions anymore,
I'm just going to shear them off.

>> I checked in 'C the Complete Reference' by the C god himself, H.Schildt.
>> He says that extern variables (and functions) are not allocated in that
>> section of the program.  Thus, I think extern, although not necessary in
>> headers, is used to reduce memory considerations.

Oh worshipper of false deities!  Had you read "The C Programming Language"
by Kernighan and Ritchie, you would have learned that there are two kinds
of ways of referring to external variables, _declarations_ and _definitions_.
Declarations announce the properties of a variable; definitions also cause
storage to be set aside.  The (file scope) declaration

	int i;

is called a "tentative definition"; if no definition with an initializer
is seen later, it will define the variable i with an initial value of 0;
otherwise, it will act the same as

	extern int i;

which is a declaration referring to some other definition.  There most be
no more than one definition of an identifier; multiple definitions of the
same identifier in a program does not result in extra copies of the variables,
it is an *error*.  It is for this reason that object declarations in header
files should contain the word "extern".

For functions, the situation is slightly different (but still the same).  This
is a *definition* of a function:

	void foo() {
		/* ok, so it isn't a very interesting function. */
	}

This is a *declaration*:

	extern void foo();

But this is ALSO a declaration:

	void foo();

because there is no function body.  Function declarations do not *need* the
keyword extern to indicate that they are declarations.

Now, there is one extra subtlety to the above (which, by the way, the Standard
(rather, the Rationale thereto) calls the "Strict Ref/Def Model".  Many
historical C implementations (in particular, the one written by Messrs. K&R)
use the "Relaxed Ref/Def Model", in which tentative definitions remain
tentative until link time; so, while the Standard considers

	file1.c				file2.c
	int i;				int i;
	foo() {				bar() {
		i = 1;				i = 2;
	}				}

to erroneously define "i" twice, the Relaxed Ref/Def model used by UNIX will
fold *all* tentative definitions in multiple translation units into one
tentative definition.  In this model, it is acceptable for header files not
to use extern to declare external data objects.
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.lang.c
Subject: Re: Variable length records
Date: 29 Jul 1992 18:27:56 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
NNTP-Posting-Host: telecaster.think.com

In article <1992Jul29.160618.27224@klaava.Helsinki.FI> wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:
>One point which I didn't think of until now (and which doesn't seem to
>have been pointed out by others) is that the '[]' and '[1]' versions
>don't allow using the structures as values, like for assignment,
>parameter passing and returning as function values.

But if you want the contents of the array portion to be copied in such
contexts, neither does your char* version.  With the [] and [1] versions
you can do the assignment using a single bcopy(), while with the char*
version you'd have to assign the structure, malloc() a new array, and then
bcopy() the old array into the new array.

Both approaches have their merits and misfeatures.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
From: tlg@uknet.ac.uk (Tim.Goodwin)
Newsgroups: comp.lang.c
Subject: Re: compiler broken?
Date: 27 Jul 92 14:43:37 GMT
Organization: UKnet

In article <1992Jul25.054848.11223@wyvern.twuug.com>,
alpha@wyvern.twuug.com (Joe Wright) writes:
>rdlin() {
>	int i;
>	for (i = 0; i < length && ((record[i] = getc(infile)) != EOF); ++i)
>		;
>	return i;
>}
>
>It worked fine on my C/80 system but failed on another i486 Unix
>system.  It turned out that if the character read was 0xff it was
>promoted to -1 (EOF) and caused an 'early' exit.  I fixed it:

You don't tell us how `record' is declared, but presumably it's an
array of char.

It seems slightly odd to me that you should conclude that your compiler
is broken:  getc() returns int (rather than char) precisely so that it
can communicate the "out-of-band" EOF, as well as any legal char.

You've already found the solution: don't convert the return value of
getc() to char until after you've compared it with EOF.

Tim.
-- 
The GNU is in fact the legendary and much-berated | ; who am i
feeping creature - Malcolm Wallace.               | uknet.ac.uk!tlg
Xref: sparky comp.lang.c:11535 comp.lang.c++:11439