HDTenEightyP/NetNews huggingface dataset:
From: tap@src.honeywell.com (Thomas A Peterson)
Subject: full type declarations within cast expressions or unary expressions
Organization: Honeywell Systems & Research Center
Date: Tue, 12 Jan 1993 18:30:16 GMT

Can someone explain to me why does C allow me to place a full type
declaration within a cast expression or as shown in the following
example within a sizeof unary expression?

main()
{
  int a;

  a = sizeof(enum colors {red, white, blue});
  {
    enum colors color = blue;
  }
}

Thanks, Tom
From: cl_fong@pavo.concordia.ca (FONG, CHEK-LAP)
Newsgroups: comp.lang.c
Subject: UUDECODE.C
Date: 9 Jan 93 20:44:00 GMT
Organization: Concordia University
News-Software: VAX/VMS VNEWS 1.41

Does anyone have the source code of UUDECODE?  If so, can you please post it 
up.  Thanks.
From: scst81@csc.liv.ac.uk (Mr. I. Rowland)
Newsgroups: comp.lang.c
Subject: use of REALLOC under UNIX system
Date: 11 Jan 93 18:16:56 GMT
Organization: Computer Science, Liverpool University


  I have a problem with some C code

  The problem centers around the ANSI function REALLOC. My function looks
  through a sorted list of names and returns a string pointer pointing to a
  to a string that contains only one instance of the name - it possible that
  many instances occur..

  The number of
  names varies at different program executions. So instead of
  declaring a large array to hold them I decided to create a pointer to a
  string (char *clast_str). As each name was discovered its length was
  calculated and enough space was allocated (using REALLOC) to contain the
  new name AND the previous names too. The new name is copied using the
  strcat function.

  However when I run this, at the first occurence of the REALLOC function

  clast_str = realloc(clast_str,bytes)     bytes = length of name + 1

                                           `+1' to account for `\0'

  the error `Bus error(coredump)' occurs.


  The full code is as follows :

  char *lithology_count (void)

  {
          int counter, record_count = 0;
          char search_str[20];
          char *clast_str;
          int bytes = 0;
     
          while (record_count < num_records)
          {
                  counter = 0;
                  printf("\nrecord count = %d",record_count+1);

                  strcpy(search_str,clast_record[record_count].lithology);
                  bytes = (strlen(clast_str)+ 1) +
                          (strlen (search_str) + 1);
/*Error Occur Here*/


                  clast_str = realloc(clast_str,bytes);


                  if (!clast_str)
                  {
                          printf("\nAllocation Error\n");
                          exit(1);
                  }

                  strcat(clast_str,search_str);
                  strcat(clast_str,",");

                  while ((record_count <= num_records) && (!strcmp
                    (search_str, clast_record[record_count].lithology)))
                  {
                          counter++;
                          record_count++;

                  }
          printf("\ncounter = %d\n",counter);
          }

          return (clast_str);
  }

  The above code runs when compiled on the Atari St using the Lattice C5
  compiler.

  I compile the above code on UNIX using :

  cc -Aa -o clast clast.c -lm

  Is there another library I should link it with. I have `included' STDLIB as
  one of my header files, the others being CTYPE and STDIO.

  I would appreciate any assistanceyou could give.

  Ian Rowland (scst81)

Keywords: 
Newsgroups: comp.lang.c,comp.lang.pascal
From: sjsobol@wariat.org (Steven J. Sobol)
Subject: Re: TPW 1.5 Controls and MDI Windows
Followup-To: comp.lang.c,comp.lang.pascal
Organization: APK Public Access Unix * Cleveland, OH
X-Newsreader: TIN [version 1.1 PL7]
Date: Wed, 6 Jan 1993 06:09:25 GMT

Carl Fago (CDF1@psuvm.psu.edu) wrote:

: Another TPW question...
: 
: Is there a method to put controls (Buttons and Icons) in the MDI client
: window?

I forgot. When you open up a window or control, you must turn
wb_MDIChild off for that window or control if you don't want it to be
treated like a normal MDI child. Otherwise it will act like a standard
MDI child. Sorry.
-- 
Steve Sobol   Head Cheerleader, APK Public Access *nix/Internet
(216) 481-9436 <2400 baud>     (216) 481-9425 <v.32bis, TurboPEP>
Telnet: wariat.org   To register: send e-mail to info@wariat.org, or
log in to BBS and download file 'user.new' from file area 2.

Also President of The Tiny Software Co.   E-Mail Address: sjsobol@tiny.com
From: scst81@csc.liv.ac.uk (Mr. I. Rowland)
Newsgroups: comp.lang.c
Subject: realloc (again)
Keywords: Realloc
Date: 11 Jan 93 19:53:30 GMT
Organization: Computer Science, Liverpool University

Following my last communication I developed another smaller program that
  uses REALLOC in the same way as my other code:

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

  #define noofstr 5

  #define bufsiz 255

  void main (void)

  {
          char *array; char buff[bufsize];
          int i;
          int bytes ;

          for (i=0; i < noofstr; i++)
          {
                  printf("Enter string %d : ",i);
                  scanf("%255s",buff);
                  bytes = strlen(buff)+1;
                  array = reilloc(array, (bytes));

                  if (array== NULL)
                  {
                          printf("Can't allocate");
                          exit(1);
                  }
          strcat (array,buff);
          }



                  printf(array);
  }



  When this program is run it ask for 5 string inputs which are strung
  together string by string using strcat. However the program seems to
  rather temperamental - sometimes it works sometimes it doesn't. For
  example

  Enter string 0 : oiuqrtq
  Enter string 1 : [qoeri
  Enter string 2 : [oqreu
  Enter string 3 : erqui                   O.K.
  Enter string 4 : [erou
  oiuqrtq[qoeri[oqreuerqui[erou


  Enter string 0 : asdfgads
  Enter string 1 : asdafadfg
  Enter string 2 : afgadfgadf
  Enter string 3 : adfgadfa
  Enter string 4 : adfgadf
  asdfgads@adfgadf                Not produced all of characters


  Enter string 0 : aasd
  Enter string 1 : adf
  Enter string 2 : asdf                     O.K.
  Enter string 3 : asdf
  Enter string 4 : asdf
  aasdadfasdfasdfasdf

  Enter string 0 : abcdefg
  Enter string 1 : abcdefgh
  Enter string 2 : abcdefghi                    O.K.
  Enter string 3 : abcdefghij
  Enter string 4 : abcdefghijk
  abcdefgabcdefghabcdefghiabcdefghijabcdefghijk


  Enter string 0 : adfgadf
  Enter string 1 : adfagdf
  Enter string 2 : adfagdf                      ?
  Enter string 3 : adfagdfg
  Memory fault(coredump)

  Enter string 0 : asdfgh
  Enter string 1 : asdfgh
  Enter string 2 : asdfgh
  Enter string 3 : sdfghjj
  Enter string 4 : asdfghjk
  Memory fault(coredump)

  Enter string 0 : a;'dfg
  Enter string 1 : a'ldfg
  Enter string 2 : 'aldfk
  Enter string 3 : 'ladfkf
  Enter string 4 : a'dlfggg

  Pid 13488 received a SIGSEGV for stack growth failure.
  Possible causes: insufficient memory or swap space,
  or stack size exceeded maxssiz.
  Memory fault(coredump)



  Is this the fault of the program? Is it the operating system? What can
  to be done to prevent it from happening?

  Again this program works on my Atari St using the Lattice C5 compiler.

  Ian Rowland (scst81)
+
From: gm08@fg30.rz.uni-karlsruhe.de (Steffani)
Newsgroups: comp.lang.c
Subject: Re: FP formats not linked
Date: 6 Jan 1993 14:03:10 GMT
Organization: University of Karlsruhe, Germany
Reply-To: gm08@rz.uni-karlsruhe.de
NNTP-Posting-Host: fg30.rz.uni-karlsruhe.de

In article <steve.00nf@Celeborn.lvunix.com> steve@Celeborn.lvunix.com (Steve Slade) writes:
>Rich Bauer (root@cpp.uucp) wrote:
>: When scanf goes to get the first batting average in this program,
>: the program terminates abnormally with the error message:
>: "floating point formats not linked"
>
>: What does this mean?  I can't find it in the manuals, and the code
>: is correct as far as I can tell.  What's the problem?
>
>: 	double b_avg[9];
>: 	  scanf("%lf", &b_avg[i]);
the problem is:       
your program dows not use floating-point functions. for this
reaseon, the linker is not orderd to link the math-lib. 
if you e. g. have a multiplication of two doubles the compiler
will tell the linker to use the math-lib (at least the microsoft
does) to solve your problem you have to find out how to link 
the math lib
hans friedrich steffani

Newsgroups: local.unix.help,comp.lang.c,comp.os.vms
From: lionel@quark.enet.dec.com (Steve Lionel)
Subject: Re: Using C to read Fortran Files
Organization: Digital Equipment Corporation
Date: Thu, 7 Jan 1993 02:59:23 GMT


In article <C0GHCC.Cwp@ccu.umanitoba.ca>, kaarts@ccu.umanitoba.ca 
(Kenneth John Aarts) writes...
> 
>>I have a fortran program that does essentially
> 
>>	open(unit=1,"test",status='new')
>>	write(1,10) 'cArt'
>>10	format(a4)
>>	end
> 
>>and then a C program that reads it:
> 
>>	int d1,d2,d3,d4,d5;
>>	FILE *fp;
>>	fp=fopen("test","r");
>>	fscanf(fp,"%c%c%c%c%c",&d1,&d2,&d3,&d4,&d5);
>>	printf("%d %d %d %d %d\n",d1,d2,d3,d4,d5);
> 
>>The output of the C program is:
> 
>>  10  65  114  116   13
> 
>>  LF  A    r   t    CR
> 
>>However, a fortran program reading the test program does see cArt.
> 

It is the VAX C Run-Time Library which is doing this to you; it "interprets"
the FORTRAN carriage control, turning the leading "c" into an LF, as that's
what would happen if you printed the line on a terminal or printer.  WHY
it does this I don't know, nor do I know how to stop it, but I thought
that at the least you should know where the problem is located.  

All I can suggest is that, if possible, open the file from FORTRAN
specifying CARRIAGECONTROL='LIST'.  I'll see what I can dig up about
solutions from the VAX C end.

Steve Lionel                    lionel@quark.enet.dec.com
SDT Languages Group
Digital Equipment Corporation
110 Spit Brook Road
Nashua, NH 03062
Newsgroups: comp.lang.c
From: misar@rbg.informatik.th-darmstadt.de (walter misar)
Subject: Re: Information about pragma directives
Date: Mon, 4 Jan 1993 08:42:34 GMT
Distribution: na
Organization: TH Darmstadt
Keywords: C language,ANSI C

In article <1992Dec30.225757.28361@hubcap.clemson.edu>, rsaripa@bach.cs.clemson.edu (Saripalli Ramakrishna) writes:
> Hi there,
> 
> 	Can someone send me some sample C code or some piece of information regarding the use of
> 	pragma directives in C(ANSI C)?.What are they really used for?.

They are just used to get gcc to play rogue :)
- 
Walter Misar                        It is impossible to enjoy idling thoroughly
misar@rbg.informatik.th-darmstadt.de       unless one has plenty of work to do.
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c
Subject: Re: ** Ack! Help again! **
Date: 11 Jan 93 17:18:34 GMT
Organization: negligable

In article <dschmitz.726261452@pv0321.vincent.iastate.edu> dschmitz@iastate.edu (Daniel C Schmitz) writes:
>In <kaNTwB1w165w@tradent.wimsey.bc.ca> lord@tradent.wimsey.bc.ca (Jason Cooper) writes:
>
>>time I use scanf or gets, and I ask for more than one input of a string 
>>in a row, like this:
>>gets(string1)
>>gets(string2)
>>or however that works (the point being they are seperate lines), C will 
>>skip some of the inputs for apparently no reason at all. 
>
>I have often had problems with scanf followed by a gets.  The first gets
>that follows any series scanf's always returns an empty string.
>A hack that has worked for me on some systems is to put a dummy gets between
>scanf's and gets's.
>
>scanf(...)
>scanf(...)
>gets(..)	/* this is a dummy, to fix problems that I've experienced */
>get(...)	/* legitimate gets, use the results */
>scanf(...)
>gets(...)	/* dummy */
>gets(...)	/* useful value */
>
>dschmitz
>dschmitz@iastate.edu

There should be no need for such a hack.
In your scanf(), does the format string contain a "\n"?
Try this:

	/* test.c */
	#include <stdio.h>
	main()
	{ 
	int i; char buf[81];

	fflush(stdin);
	scanf("%d", &i);
	gets(buf);
	printf("[%d], [%s]\n", i, buf);

	fflush(stdin);
	scanf("%d\n", &i);
	gets(buf);
	printf("[%d], [%s]\n", i, buf);
	}

log of run:

	$ ./test
	23
	[23], []
	132
	fsdljk
	[132], [fsdljk]
	$


		-Richard Hartman
		hartman@ulogic.COM

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"There are no problems, only opportunities!"
"What we have here is an insurmountable opportunity..."
Newsgroups: comp.lang.c
Subject: Best book for C (?)
From: coedgar@wisipc.weizmann.ac.il (Ron Edgar)
Date: Mon, 11 Jan 1993 20:50:51 GMT
Organization: Weizmann Institute of Science, Computation Center.

I am about to undertake C (again..) I am looking for a book which
will not assume much knowladge in os, or in other words, take me along
smoothly, I am prepered to endure stuff I alraedy know, but I hate vage
and "out of the blue" statements.
Can anyone recommend such book ?

Thanks allot.

--
+-------------------------------------------------------------------------+
| Ron Edgar            coedgar@wiscon.weizmann.ac.il  (unix)              |
| Weizmann Ins.Sci.    coedgar@wiccmail.weizmann.ac.il (MSmail)           |
| Rehovot Israel   "old chemists never die, they just reach equilibrium"  |
Newsgroups: comp.lang.c
Subject: Re: Hex escaping in strings, (porting from gcc to cc)
From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
Date: 5 Jan 93 23:37:26 GMT
Organization: Beckman Instruments, Inc.

In <1ifpjnINNkck@zephyr.grace.cri.nz> chrisp@grace.cri.nz writes:

>Hi,
>  I have a problem with porting from gcc to cc (on a sun sparc station)
>		
>	puts("\x1b=");		/* set's the terminals keypad mode */

 \033

--
Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
My opinions are my own, and do not represent those of my employer.
My interaction with our news system is unstable; please mail anything important.
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: extern: interesting case...
Keywords: extern
Date: 7 Jan 93 15:49:16 GMT
Organization: AND Software BV Rotterdam

In article <bibhas.726341439@femto.engr.mun.ca> bibhas@pico.engr.mun.ca (Bibhas Bhattacharya) writes:
|When I declare:
|extern char line[];
|for the variable "line" which was defined in another file as:
|char line[80];
|everything works fine. But when I do:
|extern char *line;
|the program dumps core. I can't figure out the difference, especially when
|extern declaration is not supposed to reserve any memory or anything. When
|I looked up K&R, the correct declaration would be: extern char line[];.
|
|Can anyone please clarify the case.

A pointer is an object that can contain the address of another object:
it `points' to the refered object. An array is simply a chunk of con-
tiguous memory refered to by its name. So:

char line[80];

defines a piece of memory (80 bytes long) and whenever you mention the
name `line', the compiler knows that you refer to those 80 bytes of memory.

On the other hand:

char line[80];

char *linep= line;

tells the compiler that the object named `linep' is a pointer, pointing
to an 80 bytes wide piece of memory that can also be refered to as `line'.

So, if you tell the compiler that there exists a piece of memory somewhere,
named `line' (extern char line[];) and somewhere else you tell the compiler
that there exists an object that can _point_ to chunk of memory (extern
char *line;) things get mixed up. If `line' is defined (in some source file)
as a chunk of memory, and somewhere else you trick the compiler, making
it believe that `line' is just an object that contains an _address_ of
something else, what else would you expect besides a core dump or a locked
up process or any other disaster you can come up with? ;-)

Does this clarify things a bit?

kind regards,

Jos aka jos@and.nl
Newsgroups: comp.lang.c,comp.lang.c++
From: dzouak@watserv1.uwaterloo.ca (Driss Zouak)
Subject: Graphics - creation, saving and loading
Keywords: graphics
Organization: University of Waterloo
Distribution: na
Date: Fri, 8 Jan 1993 01:44:18 GMT

  I need a some source code that either :
    - will allow me to load up a PCX (or other format) graphics file
    or
    - allow me to draw graphics with features like (shade, blend, etc...)

  Whether it is source, an object, an idea, address or ftp site,

please lend an electronic hand.

Driss Zouak
dzouak@watserv1.uwaterloo.ca

/////////
//  When your flying this high, you tend to forget you need air to breath
///////// 
Newsgroups: comp.lang.c
From: bobp@msi.com (Bob Pitha)
Subject: Re: Any hope for me..? 
Organization: Molecular Simulations, Inc.
Date: Tue, 12 Jan 1993 14:50:18 GMT
X-Newsreader: TIN [version 1.1 PL8]
X-Posted-From: phoenix.msi.com
NNTP-Posting-Host: sol.ctr.columbia.edu

Raphael mankin (raph@panache.demon.co.uk) wrote:
: What I am 
: looking for is people who know _more_ than programming; people who have been
: educated, not just trained; well rounded individuals, not animated machines.

: Raphael Mankin			Nil taurus excretum

  It seems to me that this is a silly criterion for hiring.  Throwing out
a potential hiree just because she has a CS degree is just as dumb as not
considering someone just because she doesn't have a CS degree.  Either one
may be a well-rounded individual, and either one may have the relevant
skills for the job.  You find out both things by conducting a good interview,
which (IMHO) does not necessarily involve trick questions such as have been
debated here in the past.
  The trick, of course, is to learn to interview well.  If you can't give
good interviews, then perhaps that is why you're relying on non-necessarily-
relevant issues to rank the applicants.  I know many people who are very
well-rounded individuals, despite the fact that they have a degree in
computers, and I know many people who are not at all well-rounded individuals
who do not have computer degrees.  I don't think there's sufficient
correlation here to justify basing hiring practices on it.
  This is, in a way, a form of discrimination.  If you rejected an applicant
because of a particular ethnic background, for example, you could be sued.
Now, before everybody starts shouting about how this is an inappropriate
analogy, consider this argument (which I am in no way espousing!): certain
cultures put a different amount of importance on learning, so a person from
(x) culture is less likely to be well-read and hard-working.  I have heard
this sort of argument from people, so it's not too ridiculous to use it as
an example.
  Of course, it is not a crime to discriminate against people on the basis
of their major course of study, so you are free to do it all you like.  It's
your hiring decision and you're free to make it as you please, as long as
you follow the laws.  But consider that you are possibly overlooking some of
the best candidates.

-----------------------------------------------------------------------
Bob Pitha                      Molecular Simulations Inc.
bobp@msi.com                   16 New England Executive Park
(617) 229-9800 x242            Burlington, MA 01803-5297
Newsgroups: comp.lang.c
From: misar@rbg.informatik.th-darmstadt.de (walter misar)
Subject: Re: adding strings together
Date: Mon, 4 Jan 1993 11:10:51 GMT
Organization: TH Darmstadt

In article <83017@mavenry.UUCP>, nider@mavenry.UUCP writes:
>  can't you just add strings together with a +, like:
>  
>  string3=string1+string2

Use LPC and it will work (unfortunately LPC is only for MUDS :)  
In C++ you could overload + on char *, I think.
But in ordinary C you have to use strcat (do an #include <string.h>).

It will look like this (ANSI version):

#include <string.h>
#include <stdlib.h>	/* for malloc	*/

char string1[]="foo", string2[]="bar", *string3;

int main(int argc, char *argv[])
{ string3=malloc(strlen(string1)+strlen(string2)+1);	/* provide storage */
  if (!string3) out_of_memory(); /* some error action	*/
  strcpy(string3,string1); 	/* copy string1 to string 3	*/
  strcat(string3,string2);	/* add string2 to string3	*/

  puts(string3);	/* or anything else you want to do with string3	*/

....
  return 0;
}

-- 
Walter Misar                        It is impossible to enjoy idling thoroughly
misar@rbg.informatik.th-darmstadt.de       unless one has plenty of work to do.
From: jar@solva.ifi.uio.no (Jo Are Rosland)
Newsgroups: comp.lang.c
Subject: Re: struct vs. typedef
Date: 10 Jan 93 14:28:29 GMT
Organization: Dept. of Informatics, University of Oslo, Norway
X-Md4-Signature: 31943765224661c43f5ea776587e1329
Originator: jar@solva.ifi.uio.no

In article <uRL4wB7w165w@cybrspc.uucp> Roy M. Silvernail writes:

   typedef struct n {
       int x,y;
       struct n *last,*next, *up, *down;
       void (*show)(struct n *);
       int width;
       void **value;
   } ITEM;

   Now, this works, but it sure seems clumsy.  Is this really the only way
   to do this type of construct?  If not, is it the optimal solution, or is
   there some extremely clever trick I'm missing?

Given C, that's the best you can get.  You'll just have to get used to
it, just like the rest of us :-).

C++ on the other hand, is another matter.  There the following code
segment is legal:

    struct node {
        node *prev;
        node *next;
        // whatever else you need
    };

    node n1;
    node *p1;
--
Jo Are Rosland
jar@ifi.uio.no
Newsgroups: comp.lang.c
From: raph@panache.demon.co.uk (Raphael mankin)
Subject: Re: compilers and code generation (struct vs. array) 
Distribution: world
Organization: Solvfield Ltd.
Reply-To: raph@panache.demon.co.uk
X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19)
Date: Fri, 8 Jan 1993 20:32:20 +0000

In article <1ihl0vINNof1@life.ai.mit.edu> sundar@ai.mit.edu writes:

>Let's say a point is defined as
>        struct point { 
>                double x, y;
>        }
>or as
>typedef double point[2];
>
>I'm interested in the usual operation on points. (i.e. 
>additions, subtractions, multiplications, co-ordinate access,
>and transformations -- i.e. multiplication by a 2x2 or 3x3 matrix 
>which again can be represented as an array or struct).
>
>Now let's look at one of these operations in detail:
>
>point_add(p1, p2, p3)
>struct point *p1, *p2, *p3;
>{
>        p3->x = p1->x + p2->x;  
>        p3->y = p1->y + p2->y;  
>}
>
>or as
>point_add(p1, p2, p3)
>double *p1, *p2, *p3;
>{
>        p3[0] = p1[0] + p2[0];
>        p3[1] = p1[1] + p2[1];
>}
>
The semantics of passing arrays and structures as arguments to functions differ.
In one case you get copying and this will have an impact on execution time. It
will also matter if you do something like:
	point_add(p1, p1, p1);
In the case of the arrays you might over-write your input values before you have
finished using them. (Not in the case of a simpel add, but think about a
complex divide operator).
-- 
--------------
Raphael Mankin			Nil taurus excretum
Newsgroups: comp.lang.c
From: acgoldis@athena.mit.edu (Andrew C Goldish)
Subject: Re: Executing DOS commands from program 
Organization: Massachusetts Institute of Technology
Date: Tue, 12 Jan 1993 18:24:53 GMT

Don't worry about it...everything's been resolved.  Thanks anyway.

					A. Goldish
Newsgroups: comp.lang.c