HDTenEightyP/NetNews huggingface dataset:
From: shepard@sampson.ccsf.caltech.edu (Ron Shepard)
Newsgroups: comp.lang.c,comp.lang.fortran
Subject: Re: calling a Fortran subroutine from a C program
Date: 26 Jan 1993 21:11:06 GMT
Organization: California Institute of Technology, Pasadena
Distribution: na
NNTP-Posting-Host: sampson.ccsf.caltech.edu

In article <1993Jan26.160622.24483@sol.ctr.columbia.edu> shenkin@still3.chem.columbia.edu (Peter Shenkin) writes:
>In article <ig25.728061129@fg30> ig25@fg30.rz.uni-karlsruhe.de (Thomas Koenig) writes:
>>An implementation might very well choose to start every character
>>variable on a word boundary, for speed reasons.
>>
>>      CHARACTER*1 STRING(100)
>>
>>would then appear to C to be an array of ints, instead of chars.
>
>I think Cray in fact does this, while placing CHARACTER*1 scalars
>on byte boundaries.
>
>	-P.

Fortran requires some storage relations to hold between character
scalars and arrays.  Most fortran programmers know this, but since
this is being posted in comp.lang.c, this may not be known to
everyone reading this thread.  In particular

    character*1   array(100)
    character*100 scalar
    equivalence  (array, scalar)

requires that array(i) and scalar(i:i) refer to the same character
storage location.  In argument passing, the "implied" length passed
with "array" is 1, whereas the length passed with "scalar" is 100.

The "array of ints" comment above is incorrect because of this
storage location requirement.  It is true that the initial
character of fortran variables and arrays is sometimes aligned to
some data boundary, but this alignment must be consistent with any
equivalence statements, and with any implied equivalences of
scalars and arrays through subroutine argument association.  The
Cray does not have "byte boundaries" since it is (64-bit) word
addressable.  Character pointers on a Cray have two pieces, a word
pointer and a character offset within the word.  The Cray C
compiler/preprocessor has builtin macros for extracting this
information from the structure used by fortran when passing
character variables as arguments.

It is sometimes simply a matter of taste as to whether characters
are referenced as array elements, array(i), or as substring
expressions, scalar(i:i).  Since Fortran 77 supports common character
operations (substring indexing, substring matching, substring
concatenation, etc.), character*1 arrays are not used in the same
way, or as often, as they are in C.

-Ron Shepard
shepard@tcg.anl.gov
Xref: sparky comp.lang.c:20203 comp.os.msdos.programmer:12457
Date: Monday, 25 January 1993 22:38:19 EST
X-Mailer: TMail version 1.14R
From: "Tim Triemstra" <empath@ais.org>
Organization: Empath Software
Subject: Re: 32 bit compilers and environments
Newsgroups: comp.lang.c,comp.os.msdos.programmer
Distribution: world

In <1993Jan25.222125.25160@news.acns.nwu.edu>, phantom@casbah.acns.nwu.edu (James Choi)  wrote:
   >1.  What is the best 32 bit fortran compiler?
   >2.  What is the best 32 bit c compiler?
   >3.  Can windows multi-task 32 bit codes? (no graphics)
   >4.  Can desq view multi-task 32 bit codes?
   >5.  Can os2 multi-task 32 bit codes?  (stupid question, but just to make
   >    sure)
 
 Question 5 is definitely not stupid, as it is very conditional.  Alot of
 DOS extenders (which are basically needed for 32bit compiled C programs)
 don't work correctly under an OS/2 DOS window.  I have gone through a few
 versions of the FlashTek DOS Extender (x32vm) for use with Zortech or
 Watcom.  The recent releases seem to work about right.  They had some
 problems with the associated mouse code to their graphics libraries but
 everything looks ok now.
 
 There are of course many different ways you can get into 32bit modes that
 WON'T work under OS/2.  I believe one is true protected mode, and I'm pretty
 sure (more sure than I am about the protected mode) that the virtual 8086
 modes WON'T work under OS/2 as that is the mode that it is already using.
 
 Worth looking into though.
 
 Tim.
 

-------------------------------------------------------
| When the end comes, there will be two men standing: |
|   Me, and the guy I gotta kill.   - Gosh I'm EVIL   |
------ Tim Triemstra ------------- empath@ais.org -----
From: wally@Auspex.COM (Wally Bass)
Newsgroups: comp.lang.c
Subject: Re: Microsoft library access from Turbo C?
Date: 23 Jan 93 22:42:11 GMT
Organization: Auspex Systems, Santa Clara

In article <1993Jan23.061158.1684@osuunx.ucc.okstate.edu>
       gcouger@olesun.okstate.edu (Gordon Couger) writes:
>In article <1993Jan22.175232.18997@progress.com>
           leary@progress.COM (Jim Leary) writes:
>>sullivan@kenyon.edu writes:
>>
>>>I have some DOS hardware with a software library to use it written for
>>>Microsoft C (ver 4.00). Is there a way to link code I write in Turbo C++ (ver
>>>2.00, I think) to this library?
>>
>
>I have tried it and it worked for me, first rattle out of the box. I didn't
>have to change a thing.

But, consider differences in the memory models, and whether that is likely
to have an impact. In particular, microsoft does (or did) assume and require
that DS=SS, as I recall, for all of their standard memory models, whereas
that generally was not true for at least the early Borland compilers.

Wally Bass

Newsgroups: comp.lang.c
From: rince@dcs.warwick.ac.uk (James Bonfield)
Subject: Re: Dynamic Allocation of Matrices
Organization: Department of Computer Science, Warwick University, England
Date: Thu, 21 Jan 1993 09:31:37 GMT

In <1jleldINN23f@manuel.anu.edu.au> stg121@ampl1.anu.edu.au (Stephen Gibson) writes:

> double **memory (int m, int n)
> {
> /* case #1 - array returned from function */
>  int i;
>  double **array;
>  array = (double **) calloc (m,sizeof(double *));
>  for (i=0;i<m;i++) array[i] = (double *) calloc (n,sizeof(double));
>  return array;
> }

Of course - this means that if you allocated an array with memory(100,2)
you'll end up consuming a lot more memory than memory(2,100) (due to all the
malloc headers). The FAQ has a better way of managing this sort of thing. It
is possible to use only one malloc (or calloc) if you're really being finicky
about memory usage:

double **memory(int m, int n) {
    int i;
    double **array1, **array2;
    array1 = (double **)calloc(m * sizeof(double *) + n * sizeof(double));
    if (array1 == -1)
	return -1;
    else {
	array2 = &array1[m];
	for (i=1; i<m; i++)
	    array2[i] = array2[0] + i * n;
    }
    return array2;
}

I don't guarantee this to work - it's all untested. But in principle you
should be able to use something like this to allocate one single block of
memory and then use the same memory for all. 

Just my half pennies worth...

	James
-- 
James Bonfield (jkb@mrc-lmba.cam.ac.uk / rince@dcs.warwick.ac.uk)
Medical Research Council Laboratory of Molecular Biology, Hills Road,
Cambridge, CB2 2QH, England. Tel: 0223 402499   Fax: 0223 412282
Date: Friday, 22 January 1993 18:22:04 EST
X-Mailer: TMail version 1.14R
From: "Tim Triemstra" <empath@ais.org>
Organization: Empath Software
Subject: Re: 32 bit C-compilers for i386/486
Newsgroups: comp.lang.c
Distribution: world

In <k3JPXB2w165w@wozzle.linet.org>, alane@wozzle.linet.org (J. Alan Eldridge)  wrote:
   >pen@lysator.liu.se (Peter Eriksson) writes:
   >
   >> No. Your program would only be subject to the GNU "bylaws" if your program
   >> would include portions of the compiler sources itself. Programs compiled
   >> from your own sources have no such restrictions.
   >
   >Or if you link in any portion of the GNU runtime library.

I remember something like that, that is why I stopped using it.  I can't
think of a time when you wouldn't use SOME of the run-time library in
an application (although I'm sure it is feasable.)  Has anyone ever written
a program that doesn't use ANY runtime library (I mean a program big enough
to actually DO something)?

Tim.

-------------------------------------------------------
| When the end comes, there will be two men standing: |
|   Me, and the guy I gotta kill.   - Gosh I'm EVIL   |
------ Tim Triemstra ------------- empath@ais.org -----
Newsgroups: comp.lang.c,comp.lang.c++
From: blume@kastle.Princeton.EDU (Matthias Blume)
Subject: Re: C/C++ Speed
Reply-To: blume@kastle.Princeton.EDU (Matthias Blume)
Organization: Dept. of Computer Science, Princeton University
Date: Fri, 22 Jan 1993 19:34:34 GMT

In article <1jnqudINNfcq@emx.cc.utexas.edu>, jamshid@emx.cc.utexas.edu
(Jamshid Afshar) writes:

[ lots of stuff deleted (actually, I tamed my urge to answer that) ]

|> C++ doesn't force one to use
|> virtual functions, and I think you can write a lot of useful classes
|> without them.

Although I started the thread against C++ I'm NOT against OOP.  And OOP
without late binding (i.e. virtual functions) does not even deserve that
name, as far as I'm concerned!

|> >Most C++ code has comments about buggy compilers, amazing as this
may sound.
|> 
|> I don't think this is amazing at all.  Buggy software is a fact of
|> life, whether that software is a compiler, os or application.

Pardon me?  I must have been under the wrong impression that C++ defenders like
C++ because it is said to be helpful in getting rid of bugs.  Interesting
to hear that they can easily get along with bugs... Again: why do you use C++?
[ I mean: getting rid of bugs by using someone else's classes ]

|> C++ goes further in that its data abstraction,
|> template, and inheritance features allow you to better implement
|> persistence.
   ^^^^^^^^^^^
Can you, please, elaborate?!

-Matthias
Newsgroups: comp.lang.c
From: arao@andy.bgsu.edu (Avinash Rao)
Subject: Re: Best way to learn C?
Followup-To: comp.lang.c
Organization: Bowling Green State Univerlity
Date: Thu, 28 Jan 1993 19:07:23 GMT

In article <1993Jan25.054814.1261@magnus.acs.ohio-state.edu>,
ctoth@magnus.acs.ohio-state.edu (Christopher M Toth) wrote:
> 
> 	Does anyone have good advice on the best way to learn C? I have
> K&R's book, but, in order to learn the stuff, I would like to write
> programs for practice, but can't come up with any good ones. Any adivice
> would be greatly appreciated....
> 
> 
> Thanks,
> 
> 
> -- 
> Christopher M. Toth             | "... We travel in the dark of a new moon
> The Ohio State University       | A starry highway traced on the map of the sky
> Columbus State                  | Like lovers and heroes,
> CIS/History/Classics/ect..Major | Lonely as the eagle's cry..." -Peart

Me too. Can anyone help?  I know C but I can't come up with good programs
to write.  Is there any book that will help me with this.
Avinash
Newsgroups: comp.lang.c,comp.lang.c++
From: herman@nosc.mil (John W. Herman)
Subject: Re: Graphics
Organization: Naval Ocean Systems Center, San Diego, CA
Date: Thu, 21 Jan 1993 21:44:09 GMT

learman@cps.msu.edu (Jerome M Learman) writes:
>I what to do some graphical programming and I want to get some comments on a 
>couple of things. I want to you high quality graphics VGA or SVGA.
*** Stuff deleted ***
I seen announcements of a software package called SUITE which does some
of this.  I think it comes with source.  Ask archie for the site
nearest you.
Newsgroups: comp.lang.c
From: dbrown@newssun.med.miami.edu (Daniel Brown)
Subject: spawnl() vs. WindExec()
Organization: University of Miami, School Of Medicine
Date: Wed, 27 Jan 1993 15:02:43 GMT

Now that I have my program working in the DOS environment, I'd like 
to run it in windows.  I'm trying to figure out how to use WindExec(),
but my on-line help says little about it.  Can anyone suggest an 
example of how to transform this spawnl() call to a WindExec() call?:

	spawnl(P_WAIT, "tiffread.exec", "tiffread.exec", "marks.tif", NULL);

Thanks in advance,

Dan
(please e-mail responses)
Newsgroups: comp.lang.c,comp.lang.fortran
From: vpham@cs.ulowell.edu (vinh)
Subject: Re: world's worst comment
Organization: University of Massachusetts at Lowell Computer Science
Date: Fri, 29 Jan 1993 02:40:24 GMT

In article <1993Jan28.201020.17169@pony.Ingres.COM> mikes@Ingres.COM (Mike Schilling) writes:
>From article <1k777jINN5j@iskut.ucs.ubc.ca>, by morgan@sitka.triumf.ca (Morgan Burke):
>> Here is my candidate for the world's most useless comment:
>> [X-windows C-code generated by XDesigner 2.0 Motif UI builder]
>> 
>> 
>> Display *display;  /* Display      */
>> 
>> 
>> -- Morgan Burke
>>    morgan@sitka.triumf.ca
>Worse would be:
>	Display *display;  /* loop counter */

why worse? i do this all the time :-)

	for (;(*(int *)display) < 10; (*(int *)display)++)
	;
Newsgroups: comp.lang.c
From: rs@cmie.ernet.in (Rajappa Iyer)
Subject: Re: What makes a good designer (was Re: Any hope for me..? )
Organization: Centre for Monitoring Indian Economy, Bombay
Date: Thu, 21 Jan 1993 07:27:24 GMT

hartman@ulogic.UUCP (Richard M. Hartman) writes:

>In article <C0w2t8.2wt@cmie.ernet.in> rs@cmie.ernet.in (Rajappa Iyer) writes:
>:I agree with you. However, the tone of Raphael's posting seemed to indicate
>:that programming ability was the *least* important criterion in hiring.

>I disagree ... he clearly said he was looking for people who knew
>more than programming, not that he was considering people who didn't
>know programming (the logical conclusion of your reading of it).

Yes... I looked again and I must eat crow. Sorry about that. :-(

>:Hmm... so what would you say go into making a good designer? Incidentally,
>:don't you find the distinction between "programmer" and "designer" or
>:"architect" unnatural?

>Between programming & design? no.  There is a definate difference.
>Between design and architect? ???.  As far as I can tell they are 
>the same thing -- tell me what you think they mean and I can tell
>you if I think that distinction is unnatural. <g>

Oh, I meant to use "designer" and "architect" as synonyms. So the
question was: "Do you find the distinction between "programmers" and
"designers" (or "programmers" and "architects") unnatural?

Let me explain why I find this concept a little unnatural. To me, the
process of programming involves making design decisions at a certain
level (e.g. choice of data structures, program structure etc.) while
that of "system design" involves decisions at a different level of
abstraction. So both "programmers" and "designers" design and calling
one a programmer and another a designer does not (to my mind) seem to
do justice to the fact that a programmer, is, in fact a designer. So
what do you think of "Program Designer" and "System Designer"?

Also, at some of the places that I have worked in, there is a concept
of a "coder" or an implementor who is supposed to mindlessly translate
program specs written by an analyst-programmer to actual code. What do
you think of such a model?
-- 
Rajappa Iyer			rs@cmie.ernet.in (Preferred)
				riyer@shakti.ncst.ernet.in
From: twv@hpcss01.cup.hp.com (Terry Von Gease)
Date: Wed, 27 Jan 1993 19:29:59 GMT
Subject: Re: strtol() return values
Organization: the Lodi Home for the Bald
Newsgroups: comp.lang.c

>/ hpcss01:comp.lang.c / ric@updike..sri.com (Richard Steinberger) /  2:57 pm  Jan 25, 1993 /
>
>	strtol() returns a long int when successful.  If a non-numeric
>string is encountered, 0 is returned.  Unfortunately, errno doesn't seem
>to be set.  Here's the question:  If a string like, "0" or "000"
>is encountered, I also get a 0 returned from strtol(). Is there an easy,
>elegant way to check for this without examing each char?  
>
>ric steinberger
>ric@updike.sri.com
>

Try this....

    char *cp;
    
    long_number=strtol(ascii_number,&cp,10);
    if (*cp)  ERROR!!!!

The pointer cp is set to the byte in the input string ascii_number that
terminated the conversion.  If the entire string was used then *cp will
point to the 0 string terminator.  If *cp is true then the string contained
characters that strtol could not cope with.

Terry
Newsgroups: comp.lang.c
From: herman@nosc.mil (John W. Herman)
Subject: Re: Legal Discussion
Organization: Naval Ocean Systems Center, San Diego, CA
Date: Tue, 26 Jan 1993 16:11:21 GMT

dave@cs.arizona.edu (Dave Schaumann) writes:

>In article <1993Jan25.165102.19959@nuscc.nus.sg>, law40003@nusunix1 (TAN YEW KEONG) writes:
*** Lot's of viperative trash deleted. ***

Ease up on the guy.  

I suggest you look at copyright, patent, and trademark law.  Spend some
time examining the international treaties and such pertaining to this
area.  Finally, make a good friend, someone you trust, who is also
getting a PhD in computer science, or better yet several friends.  Good
advice is priceless.  Remember you're a lawyer and not a technical specialist.
Newsgroups: comp.lang.c
From: steve@taumet.com (Steve Clamage)
Subject: Re: How do you read binary data piped into stdin?
Organization: TauMetric Corporation
Date: Thu, 28 Jan 1993 16:25:46 GMT

roy%cybrspc@cs.umn.edu (roy) writes:

>pdh@netcom.com (Phil Howard ) writes:

>> Unfortunately, standard C lacks a facility to change the mode of an open
>> file.  This would be what you need, and I have had situations where I need
>> this as well.

>What about setmode()?  My FM says the call is available on Unix systems.
>Is the FM lying to me?  (I s'pose it wouldn't be the first time)

Note that Phil said "standard C".  Individual implementations may
provide many functions not part of Standard C.  (I prefer to capitalize
it when referring to the ANSI/ISO Standard.)

It is not possible on many systems to change the mode of an open file
from text to binary.  Unix makes no distinction between text and binary
files, and could perhaps accomplish this trick easily.  On the other
hand, the versions of Unix I use do not have a function called setmode().
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Newsgroups: comp.lang.c
From: spectre@uiuc.edu (Ian Chai)
Subject: Summary of C++ debugger quest
Organization: Yale CS Mail/News Gateway
Date: Wed, 27 Jan 1993 03:58:34 GMT

Hi. Last week I asked about C++ debuggers. I got messages about 4 of them:

1. ObjectCenter from CenterLine		Contact nowell@centerline.com
2. Oregon from TauMetric Corporation	Contact sue@taumet.com
3. g++ and gbx from Gnu			Download from your favourite Gnu place
4. CC and dbx from Sun			Sun Microsystems

Since (1) and (2) cost extra money, I tried g++/gbx first. It was
slightly incompatible with our established base of software, so I
didn't want to use it unless compelled for it would require changing
all our code slightly. Finally, someone told us that the CC and dbx
from Sun *does* demangle the C++ in debugging. I was really puzzled
about this, since I had assumed that since we were running Sparcs, we
would already be using the Sun-supplied C++ and dbx. Well, apparently
not, for after asking around our system support staff, I obtained a CD
ROM from one of them with that and when we installed it, voila! it did
indeed demangle C++ dbx.

Thanks, everyone who helped.

				Ian Chai <spectre@uiuc.edu>
				Visual Project
				Computer Science Department
				University of Illinois at
						Urbana-Champaign
Newsgroups: comp.lang.c
From: lhjensen@fish.Princeton.EDU (Leif Jensen)
Subject: Re: Neophyte C programmer needs HELP!
Originator: news@nimaster
Organization: Princeton University
Date: Wed, 20 Jan 1993 04:49:15 GMT

In article <1993Jan19.221115.4901@organpipe.uug.arizona.edu> dave@cs.arizona.edu (Dave Schaumann) writes:
>In article <1993Jan19.213452.4531@organpipe.uug.arizona.edu>, dave@cs (Dave Schaumann) writes:
>>In article <1993Jan19.122451.10366@ac.dal.ca>, francis@ac writes:
>>>2.	If Sn denotes the number of subsets of {1,2,3,...,n} that do *not*
>>>	contain two *consecutive* integers, write an algorithm and program
>>>	to compute the value Sn for any set {1,2,3,...,n}.  For example:
>>>	S3=5 since the subsets of {1,2,3} that do not contain consecutive
>>>	integers are {}, {1}, {2}, {3}, {1,3}.

>>This one's a bit harder.

>Actually, not that hard at all... (tho, I suppose it might be harder
>for those who've never seen dynamic programming before...)

>>It might even be possible to use induction to find a formula...

>Actually, once you start generating solutions, the formula's
>pretty obvious.  Proving it's correct, on the other hand, would
>be a bit more difficult.

First consider...(created easily with vi)

S_1 = {{},{1}}
S_1*= {{3},{1,3}}
S_2 = {{},{1},{2}}
S_2*= {{4},{1,4},{2,4}}
S_3 = {{},{1},{2},{3},{1,3}}
S_3*= {{5},{1,5},{2,5},{3,5},{1,3,5}}
S_4 = {{},{1},{2},{3},{1,3},{4},{1,4},{2,4}}
S_4*= {{6},{1,6},{2,6},{3,6},{1,3,6},{4,6},{1,4,6},{2,4,6}}
S_5 = {{},{1},{2},{3},{1,3},{4},{1,4},{2,4},{5},{1,5},{2,5},{3,5},{1,3,5}}

It's not so hard to prove.  For S_n = {a1,a2,...,am}, define
S_n* = {a1 union {n+2}, a2 union {n+2},..., am union {n+2}}.  It is
easy to see that every element of S_n* is in S_{n+2} and is not an
element of S_{n+1}.  Trivially every element of S_{n+1} is in S_{n+2},
and it is simple to see that in fact all elements of S_{n+2} are also
in either S_{n+1} or S_n*.  Thus we have a recurrence relation on the
orders of the S_n: |S_{n+2}|=|S_{n+1}|+|S_n|, and the solution is
familiar from the Fibinocci sequence.

|S_n| = 5^{-1/2} (\phi^{n+2} - (-1/\phi)^{n+2}),

where \phi is the Golden Ratio (1+\sqrt 5)/2.

How would the dynamic programming solution go? (and why would it
be preferable to an analytic solution?)

--
Leif Jensen
lhjensen@phoenix.princeton.edu
Newsgroups: comp.lang.c
From: harris@scorch.apana.org.au (Michael Brown)
Subject: Re: Btree, or Linked List Questions
Organization: Craggenmoore public Unix system , Newcastle , Oz
Date: Sat, 23 Jan 1993 18:29:57 GMT

senerat@g2syd.genasys.com.au (Senerat Rajakaruna) writes:


|The right way to free a linked list is to save the next pointer of head 
|before freeing:
|	
|	LIST *p, *q;

|	for (p = head; p != NULL; p = q)
|	{
|		q = p -> next;

|		/* free any sub-elements of current head */
|		FreeData(p);
|		(void) free((void*) p);
|	}

|	/* reset head */
|	head = (LIST *) NULL;


    for(;(temp_ptr=head_ptr)!=NULL;free(temp_ptr)) head_ptr=head_ptr->next;
    
    I find that a bit more fun, myself.
-- 
 .-------------------------------------------------------------------------.
 |             Michael  Brown  at Craggenmoore Public Access Unix          |
 |                         harris@scorch.apana.org.au                      |
 |    "Your progressive hypocrites , hand out their trash.                 |
 |        But it was mine in the first place , so I'll burn them to ash."  |
 `--------------------------------------------- Peter Gabriel -------------'
Newsgroups: comp.lang.c
From: ruffalom@cs.uwp.edu (Mike Ruffalo)
Subject: cfg src
Organization: University of Wisconsin - Parkside
X-Newsreader: TIN [version 1.1 PL8]
Date: Mon, 25 Jan 1993 03:43:28 GMT

	Hi there, I am looking for some source for a one of those GREAT
configuration file data parsers. You know the ones that parse data that
resides in a text file laid out like this...

-c.h.-

PROGRAMNAME=prog
OPTIMIZE=ON
LUNCH=NOON
SLEEP=NEVER
THANKYOU=YES
MAGICWORD=PLEASE

-c.h.-

	I would be VERY thankful if anyone could mail me a construct
fragment. Thanks in advance!

-- 
///////////////////////////////////////////////////////////////////////////
			PANIC NOW AVOID THE RUSH!
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Newsgroups: comp.lang.c