HDTenEightyP/NetNews huggingface dataset:
From: ae24@iamk4516.mathematik.uni-karlsruhe.de (Peter Januschke)
Subject: Re: Simple C question 
Organization: University of Karlsruhe, Germany
X-Newsreader: Tin 1.1 PL4
Distribution: unm
Date: Tue, 1 Sep 1992 09:56:25 GMT

rsahu@triton.unm.edu (Raikanta Sahu) writes:
> I thought the following piece of code was perfectly legal.
> --------------------------------------------------------
> #include <stdio.h>
> 
> main()
> 
> {
>  char s[] = "Hello world!" ;
> 
>  printf("OK \n" ) ;
> }
> ---------------------------------------------------------
> 
> Here is what I get from the compiler.
> 
> ccom: Error: test.c, line 6: no automatic aggregate initialization
> 
> Can anybody please explain why automatic initialization is not accepted ?
> 
> Thanks.
> 
> -sahu,r 


Automatic aggregate initialization is a purely ANSI C feature.
In K&R C it is explicitely not allowed to use such an initialization.
If you want to initialize your string you have to declare it as
"static".

Peter Januschke
University of Karlsruhe, Germany
e-mail : ae24@iamk4516.mathematik.uni-karlsruhe.de  (129.13.129.16)

Newsgroups: comp.lang.c,comp.unix.programmer
From: davidr@mentorg.com (David Ransier)
Subject: Re: Realloc question
Organization: engr
Date: Fri, 4 Sep 1992 16:21:11 GMT

In article <1992Sep4.100203.1@ducvax.auburn.edu> swanger@ducvax.auburn.edu writes:
>I think I need to use realloc in a program, but I'm not sure I understand
>how to use it.  My program will dynamically allocate a two-dimension array
>of strings using calloc statements.  There is a chance that I might need
>to increase the size of this array later in the program, so I guess I need
>to use realloc.  Here is a code fragment:

I'm jumping out on a limb here, given that I am no expert.  In fact I'm kind
of a newbie here also, but it seems to me a better way to implement this is 
with a linked list, which can be extended easily, until you run out of memory.
Another alternative is to create a larger array of pointers to your strings
instead of an array of strings.  The initial memory space used by an array of 
pointers should be much smaller than allocating space for some fixed lengh
strings.
Date: Fri, 28 Aug 92 19:48:00 +0200
From: Gilles_Kohl@spam.fido.de (Gilles Kohl)
Subject: printf question
Newsgroups: comp.lang.c
X-Comment-To: (Edward H. Truex)
Organization: To take arms against a C of troubles ... 

 > main( int argc, char *argv[] ){

 > sprintf( format_string, "%%0%dx\n", ADDR_BITS/4 );
 > printf( format_string, address );

 > I would like to get rid of the sprintf statement (and the corresponding
 > format_string).  Is there a way to force a macro substitution into the
 > printf format??
Edward,

try

printf("%0*x\n", ADDR_BITS/4, address);

Btw, you may want to have a look at the '%p' format specifier, if your compiler 
supports it.

Hope it helps,
Regards,
Gilles.

---
Newsgroups: comp.lang.c,comp.sources.wanted,comp.unix.misc,alt.sources.wanted,comp.lang.fortran,comp.lang.perl,comp.lang.misc
From: ajg@controls.ccd.harris.com (Arnold Goldberg)
Subject: WANTED: C to FORTRAN translator
Organization: Harris Controls and Compositions
Date: Thu, 3 Sep 1992 16:19:48 GMT

 
I'm looking for a translator (scripts or whatever) that would translate
a C .h file to something usable by Fortran.
 
I just need to be able to translate structures, not the code.
 
It has to handle nested structures.
 
 
thanks,
 
arnold
--
------------------------------------------------------------------------
Arnold Goldberg                            Email:  ajg@ccd.harris.com
Phone: (407)242-5051                       Snail:  Harris Corporation
Fax  : (407)242-4262                               407 John Rodes Blvd.
                                                   Melbourne, FL 32905
The opinions expressed are my own and do not in any way represent Harris 
------------------------------------------------------------------------
Newsgroups: comp.lang.c
From: karl@ima.isc.com (Karl Heuer)
Newsgroups: comp.lang.c
Subject: Re: printf question
Date: 2 Sep 92 22:26:20 GMT
Article-I.D.: ima.1992Sep02.222620.4315
Organization: Interactive Systems, Cambridge, MA 02138-5302

In article <18260@acorn.co.uk> jcoxhead@acorn.co.uk (Jonathan Coxhead) writes:
>In article "Re: printf question" karl@ima.isc.com (Karl Heuer) writes:
>>The C preprocessor has no way to evaluate-and-stringise a constant
>>expression.
>
>but it does!  [Example deleted]

As Lars pointed out, your example only does the stringizing part.  I've always
found the absence of an evaluator to be annoying, since the preprocessor needs
to be able to do it anyway for #if directives; but I can live with the
limitation (or use m4 when necessary).

Hmm, I wonder if the GNU folks would be interested in adding this as a
preprocessor extension.

Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint
Newsgroups: comp.lang.c,comp.unix.questions
From: jmolinari@hamp.hampshire.edu
Subject: cursor input on curses (new prob.)
Organization: Hampshire College
Date: Wed, 26 Aug 1992 02:01:12 GMT

	A while ago I posted a question dealing with the curses library
package.  I asked how I could handle cursor input, e.g., "cursor-up, down,
etc."  Several people replied with variations of "use the keypad() function".
Problem is, keypad() doesn't seem to be implemented in our package of curses
(which is installed on a sun3 system).  It's not in the curses.h file, nor in
any of ther OTHER headers in our collection (I GREPped the directory, so I'm at
quite a loss.  If anybody can explain this and/or offer a solution, I will be
able to finish an ascii version of Minesweeper I'm working on for school.
Thank you!
			jmolinari@hamp.hampshire.edu

Xref: sparky comp.lang.c:13170 comp.sys.sun.misc:4067
From: ama@metrix.UUCP (Alan Amaral)
Newsgroups: comp.lang.c,comp.sys.sun.misc
Subject: Re: sun cc optimization failure
Date: 3 Sep 92 15:08:05 GMT
Reply-To: ama@metrix.UUCP (Alan Amaral)
Organization: Matrix Computer Systems Inc.

In article <1992Sep3.040401.16902@mr.med.ge.com> carl@aslmr-serv.med.ge.com (Carl Crawford) writes:
>
>consider the following program:
>
>main() {
>	int i,j,ax;
>	ax = 0;
>	for(i=0;i<3;i++){
>		j = ax * i;
>		puts("in for loop");
>	}
>}

By the way, if you change the ax=0 to ax=1 the problem goes away.  It also
goes away if you remove the j = ax * i; from the loop.  Apparently the
global opimizer, in trying to remove the invariant expression from the loop
(j == 0 ALWAYS if ax == 0), apparently screws up the loop variable
initialization (as I explained in my last message) which causes the code not
to loop at all. 

Adding more code to the loop, say k = ay * i; where ay = 1; will also fix
the problem.  Strangely enough the assembler code is IDENTICAL (except for
the register initialization being correct) if you add the extra code, as k
is not used in the loop, so the calculation is totally eliminated.  The
compiler apparently doesn't screw up the initialization in this case...

It looks like the compiler has problems with removing invariant expressions,
but not unused expressions...

Curiouser and curiouser...
-- 
Alan Amaral             |  Email: ama@metrix.COM
Metrix Network Systems  |  Voice: (603) 888-7000
Newsgroups: comp.lang.c
From: chans@lillee.cs.curtin.edu.au (Sean Chan)
Subject: fscanf problem...
Organization: Curtin University of Technology
Date: Fri, 28 Aug 1992 04:36:19 GMT

Gidday all,

I am trying to read a file containing a 2x2 dim array of integers. The
numbers are indented in the file...

eg.
     2   2   2   1   20   30   40   70... and so on...

I'm trying to get fscanf to read each integer at a time but I get a core
dump. It's used like this :-

      fscanf (infile, "%d", val);

Any reason why I'm getting a core dump?? Doesn't fscanf automatically
skip the spaces and read the integers only??

Sean
***********************************************************************
*			                 *                            *
* Sean Chan		                 *   Inside every microchip   *
* Student Number : 892561F	         *   there is a little man    *
* 3rd Yr. Computer Science	         *   running around doing     *
* Curtin University of Technology        *   everything you have      *
*                                        *   asked him to do...       *
* E-Mail : chans@marsh.cs.curtin.edu.au	 *                            *
*          pchans@cc.curtin.edu.au	 ******************************
*				         *
******************************************
Newsgroups: comp.lang.c
From: ckincy@mcs213c.cs.umr.edu (Charles Kincy)
Subject: Re: Novice Questions
Date: Sun, 30 Aug 1992 22:14:26 GMT
Organization: University of Missouri - Rolla

In article <1992Aug30.101121.4479@klaava.Helsinki.FI> wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:
>maven@eskimo.celestial.com (Norman Hamer) writes:
>> 1. Given a char array, say char foo[256];, is *foo the same as foo[0]
>>and is foo+x the same as foo[x] in all implementations?
>
>*foo and foo[0] are identical, and *(foo+x) and foo[x] are identical. 
>The latter is by definition: the language is defined that way.  The
>former follows directly from the latter: foo[0] <=> *(foo+0) <=> *(foo)
><=> *foo.

Beware!  If you define foo as a char[], you may not reassign foo in
any way or you will be punished by a wet noodle. =)

Example:
char foo[256];
char *roo = "Argh!";
[...]
foo = roo;

Don't do this!!!

Do this:

strcpy(foo, roo);

Many novices fall into this trap.  Arrays and pointers are *nearly*
equivalent, but not quite.

cpk
From: zaa@vax5.cit.cornell.edu
Newsgroups: comp.lang.c
Subject: 386 Not Deterministic?!?
Date: 31 Aug 92 18:25:40 EDT
Distribution: comp
Organization: Cornell University

Dear Microsoft C programming whizzes:

     I am having serious problems with a tracking program I am writing on
a 386.  My program is supposed to track the motion of a large group of
particles through a large number a digitized image frames.  The program seems
to work for smaller data sets, but for large data sets, it tends to freeze up. 
Normally this sort of thing would not perturb me greatly, but the program
freezes up at a different point every time I run it (using the same parameters
and rebooting before every trial). My question is:is the 386--Microsoft C6.0
combination deterministic?  If so, I would expect identical results every time
the pointer returned by malloc to make sure I have memory left to use.  I am
also doing RAM saves onto a RAMdisk periodically ( since I am not adept enough
to break through the 640K barrier otherwise.  Will Microsoft C 7.0

also doing RAM saves periodically onto a RAMdisk ( since I am not adept enough
to break past the 640K barrier manually.  Does anybody know whether Microsoft C
7.0 will do this automatically? ).                                                                               
     One possibility is that the image processing machine I have connected to
the 386 is generating strange indeterminate signals, but I'd rather not think
about that.

     	             Please send help!


			Totally lost in Ithaca.
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Newsgroups: comp.lang.c
Subject: Re: main()
Date: 2 Sep 92 21:53:37 GMT
Organization: University of Helsinki

jaorans@PacBell.COM (Jeff Oransky) writes:
>I would have to guess that the custom of making the main function an int
>type and returning 0 at the end is more of a necessity in UNIX C 
>programming since a program return to the operating system of 0
>indicates a successful execution or a non zero for an unsuccessful one.

The method of returning an exit code from a program to the operating
system that is used in C is copied from Unix, yes, but the fact is that
many (if not most) operating systems support (some of them require, e.g.
VAX/VMS does, I think) some kind of similar concept.  An additional,
the really compelling one, is that this exit code is actually used and
relied upon by _users_.  ``int main'' and a meaningful return value for
main are not something only Unix programmers need to do.

Also, let us not forget that the exact details of the way that a
function is called often depend on the return type of a function.  For
example, if the calling convention is such that the return value of a
function is the topmost thing on the stack after the function returns,
the caller will pop this value off from the stack.  Now, if the caller
and callee disagree about the type, we will have trouble.  In the
example with main, the caller (the operating system, or the startup
module) assumes main returns an int, and if we write main as returning
nothing, there will be _no_ value on the stack, but the caller of main
will _still_ try to pop the int that it assumes is there.  The only way
to get around this is to call main differently, but that requires
additional logic built into the compiler (it needs to link a different
startup module), something which the compiler is under no obligation to
do (since anything but ``int main'' is outlawed by the standard).

--
Lars.Wirzenius@helsinki.fi
Newsgroups: comp.lang.c
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: strcpy implementation question
Organization: Computer Science, University of Melbourne, Australia
Date: Thu, 27 Aug 1992 07:43:05 GMT

ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:

>In article <PINKAS.92Aug25163006@caraway.intel.com>, pinkas@caraway.intel.com (Israel Pinkas) writes:
>> The fact that the memory has not been initialized is irrelevant.  If the
>> source didn't care about it, neither will the destination..
>
>This is wrong.  It isn' the source or the destination that cares, it is
>strcpy() that cares.  strcpy() MUST NOT READ any uninitialised memory
>locations.

I'm sorry, but this is wrong.
The code to implement strcpy() does NOT have to be ansi-conformant - hell,
it doesn't even have to be written in C! It IS allowed to read
uninitialised memory locations, so long as that doesn't stop it doing its
job correctly.

The following function correctly implements strcpy on my machine:

	#define MINDLESS_USE_OF_UNITIALIZED_MEMORY 

	char *strcpy(char *dest, const char *src) {
	    char *retval = dest;

	#ifdef MINDLESS_USE_OF_UNINITIALIZED_MEMORY
	    char unused[4];
	    unused[0] = (unused[1] *= (unused[2] += unused[3]));
	#endif

	    while (*dest++ = *src++) ;
	    return retval;
	}

It might not work on *your* machine, but that's irrelevant.

If the compiler can determine that there referencing memory past
the end of the string will not cause any side-effects, then it is perfectly
entitled to do so.
[Of course, strcpy is not allowed to write past the end of the destination
string, because that *would* cause detectable side-effects.]

-- 
Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
This .signature virus is a self-referential statement that is true - but 
you will only be able to consistently believe it if you copy it to your own
.signature file!
Newsgroups: comp.lang.c,comp.sources.wanted,comp.unix.misc,alt.sources.wanted,comp.lang.fortran,comp.lang.perl,comp.lang.misc
From: siili@sumppu.fmi.fi (Tero Siili)
Subject: Re: WANTED: C to FORTRAN translator
Originator: siili@sumppu.fmi.fi
Organization: Finnish Meteorological Institute
Date: Fri, 4 Sep 92 06:59:52 GMT


I would also be interested in something similar - a script (sed, awk, whatever), which would convert #define's to e.g. parameter-statements.

Tero Siili
Finnish Meteorological Institute
Tero.Siili@fmi.fi
Newsgroups: comp.lang.c
From: danielbt@marsh.cs.curtin.edu.au (Brett Daniel)
Subject: Extracting C functions from Source files
Keywords: C functions source files
Organization: Curtin University of Technology
Date: Tue, 1 Sep 1992 01:44:03 GMT

I am looking for some software to extract C functions from source files.  I've
a version of "csplit" but it does not seem to work correctly on all source
files.  If someone can tell me where to find software that will perform this 
function I would really appreciate it.

--

Brett Daniel
School of Computing Science
Curtin University of Technology
Western Australia.
email: danielbt@cs.curtin.edu.au
From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
Newsgroups: comp.lang.c
Subject: Re: printf question
Date: 2 Sep 92 12:41:31 GMT
Organization: University of Helsinki

jcoxhead@acorn.co.uk (Jonathan Coxhead) writes:
>         The C preprocessor has no way to evaluate-and-stringise a constant
>      expression.
>
>but it does!
>
>[ C code deleted, but it's almost the same as the code below, but with
>  WIDTH defined as 8 only --liw]

Input to preprocessor:
	#define STR_(s) #s
	#define STR(s)  STR_ (s)
	#define WIDTH 8+2
	printf ("%" STR (WIDTH) "x", n);

Output from preprocessor (with empty lines removed):
	# 1 "foo.c"
	printf ("%"  "8+2"   "x", n);

Nope, the C preprocessor does not evaluate 8+2 into 10.

(Not that I'm not saying that it should, since it clearly shouldn't,
especially in this case, 'cause it can't know whether 8+2 or 10 is
wanted.)

--
Lars.Wirzenius@helsinki.fi
From: jon.ault%travel@wugate.wustl.edu (Jon Ault) 
Newsgroups: comp.lang.c
Subject: How to fprintf two column
Date: 26 Aug 92 20:52:00 GMT
Distribution: world
Organization: Travel Online, St. Louis, MO
Reply-To: jon.ault%travel@wugate.wustl.edu (Jon Ault) 

VA. I need the following output to a file:
  . 1.2     2.3
  . 1.3     2.4                    1.4     2.5
  . ....
  . which contains two columns. They are not generated at the same 
  . time, i.e. at the first the first column is generated and then 
  . write to a file. then the file is rewinded and the second column is 
  . generated. Now I need write the second column to that particular 
  . place, say begin with 10th column. I have tried fseek() but it  
  . seems to me not working. (?)

I would approach this by writing the first column out to a temp file, 
then reading it back in and appending the second column, writing that 
out to the final output file.  Or, save the first column in some kind 
of array, then write both columns at once.

Jon
---
 . DeLuxe./386 1.25 #124sa .
From: MIKEL@LIVERPOOL.AC.UK
Newsgroups: comp.lang.c
Subject: 'NEW', Big arrays and Turbo C
Date: 27 Aug 92 10:17:37 GMT
Organization: University of Liverpool

Is there some problem please with segmentation in Turbo C++ version 2, I have
tried to get the following test code to work with various memory models,
setting the pointers to huge etc. The source works happily on Suns, but crashes
on PCs using Turbo C++ v2:

#include <stdio.h>
//#include <conio.h>

main()
{
  int dimension = 20000;
  int i;
  float *test ;
  float *test2 ;
  if (!(test=new float [dimension]))
    {
   printf("NO RAM");
	exit(1);
}
  if (!(test2=new float [dimension]))
{	
  printf("NO RAM 2");
	exit(2);
}
  for(i = 0; i < dimension; i++)
  {
    test[i] = (float) i;
    test2[i] =(float) i;
  }
  printf("\nThese are the arrays\n");
  for (i = 0; i < dimension; i+=100)
    printf("test[%d] = %f, test2[%d] = %f \n", i, test[i], i, test2[i]);
}

My suspicion is that, irrespective of memory model and ptrsize, the thing
is falling over after a segment boundary is reached.

Mike Lewis TheUniversity of LiverpoolUK
Newsgroups: comp.lang.c
Subject: Reading PC CMOS using Borland C
From: $dougn@sasb.byu.edu (Douglas R. Nebeker - MIS_SAS)
Date: 27 Aug 92 14:35:27 -0700
Organization: Brigham Young University
Keywords: CMOS C

Hello 

I posted this earlier, but asked the wrong question--my appologies to those 
that read it...here's the real thing:

I am using Borland C and trying to read the CMOS in my PC.  Does anyone have 
any experience doing this?  Do I need to read from a port?  Any hints or 
help would be very welcome.

Thanks

___
Douglas R. Nebeker                             Internet: $dougn@sasb.byu.edu
Brigham Young University
SAS Computer Support
Xref: sparky comp.lang.c:12868 comp.std.c:2526
From: eht@coos.dartmouth.edu (Edward H. Truex)
Newsgroups: comp.lang.c,comp.std.c
Subject: printf question answered
Date: 27 Aug 92 17:20:22 GMT
Organization: Dartmouth College, Hanover, NH

If any one out there was wondering how to include #define'd macros
in the format string of printf ( as I was ) here is the solution
(Thanks to the folks who responded so promptly)

1. RTFM (look for the * qualifier)

2. If that doesn't work use the following as a template.

	#define ADDR_BITS 16

	.......

	printf ("%0*x\n",ADDR_BITS/4, address );

 this prints the value of address as a 0 padded 4 hexit number.

Thanks again,
Tad
Xref: sparky comp.lang.c:13139 comp.std.c:2563
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.lang.c,comp.std.c
Subject: Re: strcpy implementation question
Date: 3 Sep 1992 05:07:19 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
NNTP-Posting-Host: gandalf.think.com

In article <BtxB7w.6yH@cup.hp.com> decot@cup.hp.com (Dave Decot) writes:
>Although the C standard does not say strcpy() can clear all variables named
>"ferdinand", it also does not say that printf() can cause phosphors to
>glow a different color on a monitor connected to the computer.
>
>So, this is not, in itself, enough criteria to prevent the former.

No smiley, so I'm going to take you seriously....

Neither does ths standard say that 3+4 causes the transistors in the adder
circuit to change state, but somehow we all know that it does.

The fact is that the intended audience of language standards is computer
professionals, who are assumed to be familiar with the basics of computer
operations, such as how computations are performed and how I/O is done.  If
the standard authors couldn't assume some common background with the
readers, they'd be stuck trying to explain everything from first principles
(and perhaps unnecessarily limiting the applicability of the standard --
suppose the original Fortran spec had been written in terms of vacuum tube
behavior, requiring it to be updated to be applicable to transistors).

-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar
Lines: 3
Date: Wed,  2 Sep 92 09:44:52 MDT
Newsgroups: comp.lang.c
Subject: Re: Graphcs Gems Books
Organization: Brigham Young University, Provo UT USA
From: gaow@bones.et.byu.edu (Jinsong Gao)

Ooops! I posted to the wrong group.  

Sorry for the mix up. 
Newsgroups: comp.lang.c,comp.sources.wanted
From: nirad@newdelphi.ceu.uq.oz.au (Nirad Sharma)
Subject: hsearch with multiple tables
Organization: Continuing Education Unit, The University of Queensland
Date: Sat, 29 Aug 1992 11:00:16 GMT

I'm looking for an implementation of hsearch(3) that works with more than
one table of hash values and is dynamically extensible i.e. not limited to
some startup length.  Any pointer much appreciated.
--
Nirad Sharma  (nirad@ceu.uq.oz.au)			Phone : (+61 7) 365 7575
Continuing Education Unit				Fax :	(+61 7) 365 7099
The University of Queensland.  QLD  4072.  AUSTRALIA
Newsgroups: comp.lang.c
Subject: Re: Pascall Typed Files
From: a_rubin@dsg4.dse.beckman.com (Arthur Rubin)
Date: 1 Sep 92 19:36:36 GMT

In <10270@vice.ICO.TEK.COM> bobb@vice.ICO.TEK.COM (Robert Beauchaine) writes:

>  Floats do not exist in Turbo Pascal, at least not by that name.
>  The C float type is a the IEEE 4 byte real, which is called a
>  "single" in Turbo Pascal.  If you need double precision, then both
>  languages use the IEEE double type. 

Well, actually, the default is the IBM Basic 6-byte real; and you can
change it to use IEEE 4-byte or IEEE 8-byte real.
--
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; if you want to be sure I see a post, mail it.
From: sun@cco.caltech.edu (Neal K. Chaudhary)
Newsgroups: comp.lang.c
Subject: Problem on Sun4
Date: 24 Aug 92 00:47:25 GMT
Organization: California Institute of Technology, Pasadena

How do you get the idle time of a 
tty using C lib functions (a la finger).
There's nothing in TFM.
Is there any site where you can ftp
sources to stuff like this?

-Neal
Newsgroups: comp.lang.c