HDTenEightyP/NetNews huggingface dataset:
From: steve@dbaccess.com (Steve Suttles)
Newsgroups: comp.lang.c
Subject: Re: Why C over FORTRAN
Date: 28 Jan 93 20:04:50 GMT
Organization: Cross Access Corp., Santa Clara, CA
X-Newsreader: Tin 1.1 PL4

jm59@prism.gatech.EDU (MILLS,JOHN M.) writes:
: In article <RVILLA.93Jan27211009@navier.ae.utexas.edu> rvilla@navier.ae.utexas.edu (reynaldo villarreal) writes:
: >
:  >I am interested in the pros and cons of C vs. FORTRAN.(gcc vs f77 on a
:  >Sun) I have to write code and have to give an informed choice to my
:  >advisor on which to use.
: 
: If you want more that religious answers, you should be more specific as
: to what you wish to program, and probably cross post to another language
: group or two.  I would expect a couple of weeks worth of dogma and flames,
: anyhow.  Press, et. al., in their Numerical Recipies series address pros
: and cons, but basically as seen by Fortran programmers.  I would consider
: the code I _did_not_ have to write, i.e., libraries and toolsets, in making
: this decision.

Good response.  A very wise man (my father) used to tell me:  "It is possible
to do anything with anything.  But it is -so- much easier if you have the right
tool for the job."  Another good place to start--evaluate the relative
strengths and weaknesses of the tools at your disposal (Fortran and C in this
case).  Always pick the best tool for the job.  A good way to get an indication
of the relative strengths and weaknesses of programming languages is to look
around at what's written in them.  Tradition has it that Fortran is real strong
at numbercrunching applications, and C is best suited for character and text
stuff.  I have my own opinions (which differ), but if you are writing a lunar
launch simulator, you'd be hard pressed to justify C over Fortran.

sas
-- 
Steve Suttles                Internet:  steve@dbaccess.com      Dr. DCL is IN!
CROSS ACCESS Corporation     UUCP: {uunet,sgiblab}!troi!steve  Yo speako TECO!
2900 Gordon Ave, Suite 100   fax: (408) 735-0328              Talk data to me!
Santa Clara, CA 95051-0718   vox: (408) 735-7545   HA! It's under 4 lines NOW!
Newsgroups: comp.lang.c
From: ronenp@tiger6.technion.ac.il (Ronen Perets)
Subject: Needed C-compiler sources.
Organization: TECHNION - Israel Institute of Technology
Date: Wed, 27 Jan 1993 10:21:22 GMT

	Does anybody know if there are a C-Compiler sources
(for any processor) which are public domain and where I can get them ?

				THANKS

				RONEN

	Email: ronenp@tiger.technion.ac.il
Newsgroups: comp.lang.c
From: steve@taumet.com (Steve Clamage)
Subject: Re: strtol() return values
Organization: TauMetric Corporation
Date: Tue, 26 Jan 1993 17:16:31 GMT

ric@updike..sri.com (Richard Steinberger) writes:


>	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?  

Unfortunately not.  Of course, you don't have to examine the whole
string.  You only have to look at the first non-whitespace
character when the returned value is zero.  If that character is
'0', you have an actual zero value.  If it is null, you had only
whitespace in the string.  Otherwise, it was not a numeric value.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
From: scst81@csc.liv.ac.uk (Mr. I. Rowland)
Newsgroups: comp.lang.c
Subject: Use of ANSI qsort
Keywords: qsort
Date: 22 Jan 93 16:35:41 GMT
Organization: Computer Science, Liverpool University

I am using the ANSI function qsort to sort an array of structs. The struct is as follows :



struct clast_item{
				    int rank, a,b,c;
					double tnd_mm, tnd_phi, sphericity;
					float ab_ratio, flatness_index, volume, area;
					int roundness;
					char lithology[2];
					char zing;
				 };

The sorting key is lithology and the qsort function is called in the following routine:

void sort_tnds(void)
{
qsort((char *) clast_record,
	    (unsigned) num_records, 
		sizeof(struct clast_item),lithology_compare);
}


The lithology_compare function is as follows :

int lithology_compare (struct clast_item *a, struct clast_item *b)

{

	return strcmp(a->lithology,b->lithology);
}

When the code is compiled in its host program under UNIX the following warnings are declared :

warning 604: Pointers are not assignment-compatible.
warning 563: Argument #4 is not the correct type.

The program works i.e. the array is sorted correctly, but I would like to eliminate the warnings. 


I also have a similar problem that uses tnd_mm as the sorting key : the compare function is :

int tnd_compare (struct clast_item *a, struct clast_item *b)

{

	double tnd1 = a->tnd_mm;
	double tnd2 = b->tnd_mm;
	

	if (tnd1 > tnd2 ) return (-1);
	if (tnd1 == tnd2) return (0);
	else return(1);
}

Any help would be gratefully appreciated.

Frustratingly

Ian Rowland

P.S. Thanks to all of you that helped me with the MALLOC and REALLOC functions.
Newsgroups: comp.lang.c
From: karim@bnrmtl.bnr.ca (Karim Younes)
Subject: Preprocessor question
Keywords: Preprocessor, string
Organization: Bell-Northern Research Montreal, Canada.
Date: Mon, 25 Jan 93 16:14:25 GMT

I am trying to have a #defined variable recognized by the
preprocessor inside a string. In other words, I want to
do something like this:

#define JUNK 50
static char *junk = "JUNK ways to leave your lover."

Now the preprocessor ignores JUNK, because it is inside the double
quotes. Is there any way to get around this ? Please respond 
by e-mail or by followup, I will post a summary if needed. Thanks.

-- 
Karim "Kouki" Younes                      Bell-Northern Research
karim@bnr.ca                              Montreal, Canada

Newsgroups: comp.lang.c
From: bandy@netnews.jhuapl.edu (Mike Bandy)
Subject: Re: Legal Discussion
Organization: JHU/Applied Physics Laboratory
Date: Tue, 26 Jan 1993 16:45:50 GMT

law40003@nusunix1.nus.sg (TAN YEW KEONG) writes:

Given the statements made below, why would anyone come to you for
advice?  When I give someone computer advice, I either say "I don't
know" or give them the answer.  Sometimes I'm wrong, but everyone can
deal with that.  It looks like what you're saying is "I don't know shit
and if I give you the wrong answer and you get into trouble for it, you're
on your own".  I'll pay for my legal advice, thanks.

Mind if I borrow this?  You won't sue me, will you?  I'm going to start 
tacking this onto all computer related correspondence I give, whether 
through the Internet or via inter-office memo.  My boss will love it.

>Disclaimers :

>I will not be liable for any prosecution, both civil and criminal,
>arising in any way connected to our discussion, whether it may be
>your reliance on our discussion, or our discussion leading to criminal 
>behaviour.

>Nobody should regard our discussions as final and conclusive, and I do not
>profess any expert knowledge whatsoever.

>I disclaim responsibility for any losses you incur by relying on our 
>discussions, and if any of our discussions lead to criminal behaviour,
>let it be known that I have no knowledge of collaboration with any
>criminal.

>I wonder if this disclaimer works, but it sure sounds legal. But I mean
>all this mumbo jumbo, and if my drafting skills leave much to be
>desired, read it in spirit, not in form.
-- 

	Mike Bandy
	bandy@aplcomm.jhuapl.edu
	Johns Hopkins University / Applied Physics Lab
Xref: sparky comp.lang.c:20097 comp.lang.fortran:5140 sci.engr.mech:831
From: morgan@sitka.triumf.ca (Morgan Burke)
Newsgroups: comp.lang.c,comp.lang.fortran,sci.engr.mech
Subject: Re: SI Units Quiz
Date: 23 Jan 1993 01:57:55 GMT
Organization: TRIUMF, Vancouver BC
Distribution: world
NNTP-Posting-Host: sitka.triumf.ca

In article <1993Jan21.095736.20138@hemlock.cray.com>, jjd@cray.com (Jeff Drummond) writes:
|> Too easy.  Here's the prefix table from our units(1) command:
|> 
|>         1e-24,  "yocto",
|>         1e-21,  "zepto",
[ ... ]
|>         1e21,   "zetta",
|>         1e24,   "yotta",
|> 
|> The first two and last two were recent additions, as you probably know
|> (see "Science News", 1/16/93).
[ ... ]
|> "10 yottaflops is a lotta flops."   -me

I propose a further extension:

        1e-30,  "groucho",
        1e-27,  "harpo",
and,
        1e27,   "harpi",
        1e30,   "grouchi",

sorry, couldn't resist...

-- Morgan Burke (morgan@sitka.triumf.ca)
Xref: sparky comp.lang.c:20255 comp.lang.pascal:8570 comp.os.msdos.programmer:12481
From: rfries@sceng.ub.com (Robert Fries)
Subject: Re: Preprocessor question
Keywords: Preprocessor, string
Organization: Ungermann Bass
Date: Mon, 25 Jan 1993 17:34:17 GMT

In article <1993Jan25.161425.27962@bnrmtl.bnr.ca> karim@bnrmtl.bnr.ca (Karim Younes) writes:

>I am trying to have a #defined variable recognized by the
>preprocessor inside a string. In other words, I want to
>do something like this:

>#define JUNK 50
>static char *junk = "JUNK ways to leave your lover."

>Now the preprocessor ignores JUNK, because it is inside the double
>quotes. Is there any way to get around this ? Please respond 
>by e-mail or by followup, I will post a summary if needed. Thanks.

>-- 
>Karim "Kouki" Younes                      Bell-Northern Research
>karim@bnr.ca                              Montreal, Canada


Adjacent strings are concatenated, at least in ANSI C.
So you can do:

#define JUNK "50"
static char *junk = JUNK" ways to leave your lover."

During pre-processing, the definition of junk becomes:
static char *junk = "50"" ways to leave your lover."

The two string are concatenated, so junk becomes a pointer to the following 
string:
"50 ways to leave your lover."

In your example, you wanted to replace the first word in a string.
If you wanted to replace a word somewhere in the middle of the string,
you could do the following:

#define JUNK "50"
char *junk = "There are "JUNK" ways to leave your lover."

In this case three strings are concatenated into one.

I hope this helps.

Robert


//////////////////////////////////////////////////////////////////////////
Robert Fries
Ungermann-Bass Inc.

DISCLAIMER:
    Opinions contained herein are my own, and are not necessarily those
    of Ungermann-Bass.
//////////////////////////////////////////////////////////////////////////
Xref: sparky comp.lang.c:20192 vmsnet.alpha:152 cern.alpha:34
From: crilly@flotsm (Patrick Crilly)
Newsgroups: comp.lang.c,vmsnet.alpha,cern.alpha
Subject: Re: function arg.'s in Alpha's DEC C
Date: 26 Jan 93 01:41:38 GMT
Organization: Digital Equipment Corporation
X-Newsreader: Tin 1.1 PL4

Cast a as a pointer to a function returning int ( as defined in your
prototype )

 q ( (int (*)()) a );

Patrick
Newsgroups: comp.lang.c
From: nmp@mfltd.co.uk (Nic Percival (x5336))
Subject: Re: f2c
Reply-To: nmp@mfltd.co.uk
Organization: Micro Focus Ltd, Newbury, England
Date: Thu, 28 Jan 1993 16:21:43 GMT


In article <1993Jan28.094601.14840@hippo.ru.ac.za>, robin@ruchem.ru.ac.za writes:
> I'm trying to translate a simple Jacobi eigen-value/vector routine from
> Fortran. f2c bombs: it complains about RETURN if i try to translate the
> jacobi sub by itself, and if i append it to a short driver prog f2c
> complains about the words SUBROUTINE and RETURN, and mentions an error
> insegmentation. I'm doing this on a SUN but i want C code compatibble 
> with Turbo C 1.0. looking at the manual (man f2c) does *not* help, can
> anyone tell me what i'm doing wrong?
> Robin
> robin@ruchem.ru.ac.za
I can't really follow what you mean from what you've said, I suggest you post
a short code fragment

Cheers,
-- 
  Nic Percival      |                               |
  Micro Focus       | "Anything is good and useful  |   nmp@mfltd.co.uk
  Newbury           |  if it's made of chocolate.." |   (0635) 32646 Ext 5336 
  Berks, RG13 1JT   |                               |
Newsgroups: comp.lang.c
From: pmchoi@uxmail.ust.hk (Sam P. M. Choi,Rm 4001A,ph# x7024,no way!!!)
Subject: Re: Fairly simple text-entry help needed
Reply-To: pmchoi@uxmail.ust.hk
Organization: Hong Kong University of Science and Technology
Date: Wed, 27 Jan 1993 07:36:03 GMT

In article 47v0@aldhfn.akron.oh.us, Dean_Wagner@aldhfn.akron.oh.us (Dean_Wagner) writes:
> I'm working on a program, and I want a person to be able to enter their name
> (up to 30 characters).
> scanf doesn't work because you can only enter non-whitespace.  I could
> probably translate the whitespace by scanning one character at a time, but
> that can't be the easiest way to do it.
> gets won't work becauI can't check for max position.
> getche isn't working either...here's what I'm doing now...
> 
> while ((i < 29) && (string[i]))
>      i++;
>      string[i] = getche();
> 
> printf("%s", string);
> 
> 
> I know this isn't technically correct, but you see what I'm doing.  The 
> manual I read says while (string[i]) should work, but it doesn't seem to be,
> so I changed it to while {string[i] != '\r') || string[i] != '\n'
> 
> I think it should register \r as enter, but I'm not sure.
> It prints absolutely nothing for the printf statement in this form.  Can
> anybody suggest any fixes, or any alternate ways of doing this?
> 
> Just for arguement, I'm using Microsoft C v600a, running under os2.  I'd put
> it under DOS, but both the compiler and DOS would need re-installed, and I
> just don't have that kind of time while at work.
> 
> Thanks...
> 
> --
> Dean Wagner                        Nothing matters but the weekend
> Dean_Wagner@aldhfn.akron.oh.us    From a Tuesday point of view
> bx451@cleveland.freenet.edu             -Switch into Glide, The Kings


Did you try the following?

char string[31]; /* reserve one char for NULL */

scanf("%30[^\n]", string); 
/* read in 30 chars (including white space) or less if <cr> is encountered */

which should work on any ANSI C conformant compiler.


,----------------------------v-------------------------.
|  Sam P. M. Choi            |  pmchoi@uxmail.ust.hk   |
|  Dept of Computer Science  |  Tel: (852)358-7024     |
|  HKUST, Clear Water Bay    |  Fax: (852)358-1477     |
|  Hong Kong                 |                         |
`----------------------------^-------------------------'

Newsgroups: comp.lang.c
From: pdh@netcom.com (Phil Howard )
Subject: Re: How do you read binary data piped into stdin?
Keywords: stdin, redirection, binary data
Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
Date: Tue, 26 Jan 1993 01:23:08 GMT

chorn@eastwind.mcds.com (Christopher Horn) writes:

>I'm relatively new to C, so still have a lot to learn, so I apologize
>if this is a silly question. I need to read raw binary data from
>stdin (it is being piped in) but it appears stdin operates in text
>mode. The first ascii 26 that comes along triggers end of file, and
>I can't read the rest of the data. Could someone please explain, or
>better yet show me a short peice of code, that could do this? The
>answer is probably obvious, but it eludes me at the moment. Thanks
>a lot!

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.

You could use the system specific I/O facilities, such as for many systems
the POSIX interface.  On UNIX, simply read from file descriptor 0.  Programs
like UNIX uncompress, would be doing this (and not using stdio).

Portability?  Like I say, standard C didn't include this capability.
This is one of the cases for something that you just cannot get any
portability.  Maybe the next version of ANSI C?

If portability is not the issue for you, and you are working on a finit
set of systems, but you need to use the stdio library, you could investigate
the implementation dependent structure FILE and see what hack you could do
(perhaps changing a flag bit) to change the mode from text to binary.
It might not work on many systems, however.




> ---
> Christopher Horn           |  "We're all caught in a state of decay..."
> chorn@eastwind.mcds.com    |  The East Wind  +1 201 875 7063
-- 
/************************************************************************\
| Phil Howard,  pdh@netcom.com,  KA9WGN    Spell protection?  "1(911)A1" |
| "It's not broken... it's just functionally challenged" --Phil and Pete |
\************************************************************************/
From: ray@rann.sbi.com (Raymond Blum)
Newsgroups: comp.lang.c
Subject: Re: Prodigy_CompuServe_AmericaOnline
Date: 21 Jan 93 18:16:06 GMT
Reply-To: ray@rann.sbi.com
Organization: Salomon Inc.


  Compuserve: compuserve.com 1-800-848-8990  Tymnet, SPrintnet, CIS net access only as far as I know
  America Online: aol.com 1-800-827-6364  Tymnet or Sprintnet access
  Prodigy: bite your tongue!
---Raymond
---
------------------------------------------------------------------------
-----                                                              -----
-----                                                              -----
----                  \\\\\\\                                       ----
----                 \\\    \\   People ask me                      ----
----                  \\ o o       "Why are you smiling?"           ----
----                             I'm just happy!                    ----
----                     \_/                                        ----
----                                                                ----
----   Raymond Blum                                                 ----
----   ray@rann.sbi.com                                             ----
----   (201) 896-7594                                               ----

  Of course these are MY opinions! Whattya think, my EMPLOYER 
  could've thought this stuff up?
Newsgroups: comp.lang.c
From: darcy@druid.uucp (D'Arcy J.M. Cain)
Subject: Re: HALLOC and HUGE ptrs in Microsoft C
Date: Wed, 27 Jan 1993 23:57:07 GMT
Distribution: world,local
Organization: D'Arcy Cain Consulting

darcy@druid.uucp (D'Arcy J.M. Cain) writes:
>#ifdef __MSDOS__
>#define halloc malloc
>#endif

Of course I meant "#ifndef"

-- 
D'Arcy J.M. Cain (darcy@druid.com)  |
D'Arcy Cain Consulting              |   There's no government
Toronto, Ontario, Canada            |   like no government!
+1 416 424 2871          DoD#0082   |
From: stg121@ampl1.anu.edu.au (Stephen Gibson)
Newsgroups: comp.lang.c
Subject: Dynamic Allocation of Matrices
Date: 21 Jan 93 06:08:45 GMT
Reply-To: stg121@ampl1.anu.edu.au (Stephen Gibson)
Organization: Australian National University
NNTP-Posting-Host: 150.203.15.16

Dynamic allocation of matrices.

I would like to be able to generate arrays of various sizes and types
by calling a function such as

      memory (array1,array2,array3);

where the prototype could be:

     void memory (double **,double **,int **);

From test cases, see below, it appears that only the following works:

     array1 = memory ();

What is the difference between 
        double **function (void)    and   void function (double **) 
 with respect to  double **  ?

Any helpful comments would be appreciated.
                
                    Steve.
-----------------------------------------------------------------------------

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

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;
}

void memory2 (int m, int n, double **array)
{
/* case #2 - array passed as a function parameter */
 int i;
 array = (double **) calloc (m,sizeof(double *));
 for (i=0;i<m;i++) array[i] = (double *) calloc (n,sizeof(double));
}

void main ()
{
 int i,j,m,n;
 double **a,**b;

 printf ("Enter array size m, n -> ");
 scanf ("%d%d",&m,&n);

 printf ("Case #1\n"); 
 a = memory (m,n);
 for (i=0;i<m;i++) 
  for (j=0;j<n;j++) a[i][j] = i+j+1;
 for (i=0;i<m;i++) {
  for (j=0;j<n;j++) printf (" %lg",a[i][j]);
  printf ("\n");
 }

 printf ("Case #2\n"); 
 memory2 (m,n,b);
 for (i=0;i<m;i++) 
  for (j=0;j<n;j++) b[i][j] = i+j+1;
 for (i=0;i<m;i++) {
  for (j=0;j<n;j++) printf (" %lg",b[i][j]);
  printf ("\n");
 }
 exit (EXIT_SUCCESS);
}


-------- compilation on DEC 5000/125 ---
cc -o helpme helpme.c
-------- execution ---------------------
helpme
Enter array size m, n -> 2 3
Case #1
 1 2 3
 2 3 4
Case #2
Segmentation fault
Newsgroups: comp.lang.c
From: somesh@watson.ibm.com ()
Subject: Need info on shareware C/C++ tutor
Date: Tue, 26 Jan 1993 16:57:48 GMT
Distribution: us
Reply-To: somesh@watson.ibm.com
Disclaimer: This posting represents the poster's views, not necessarily those of IBM
Organization: IBM, T. J. Watson Research Center
Keywords: C/C++ tutor, Coronado

I am looking for a C/C++ tutorial which is available as shareware.
I know that Coronado enterprises had this. Is is available for
anonymous ftp from any source? (archie could not find anything
under tutor or coronado)

Thanks 

Somesh
Newsgroups: comp.lang.c,comp.lang.fortran
From: shenkin@still3.chem.columbia.edu (Peter Shenkin)
Subject: Re: calling a Fortran subroutine from a C program
Organization: Dept. of Chem, Columbia U, New York
Date: Wed, 27 Jan 1993 17:08:39 GMT
Distribution: na
X-Posted-From: still3.chem.columbia.edu
NNTP-Posting-Host: sol.ctr.columbia.edu

In article <1k49dbINNeij@gap.caltech.edu> shepard@sampson.ccsf.caltech.edu (Ron Shepard) writes:
>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....  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....
>
>The "array of ints" comment above is incorrect because of this
>storage location requirement....

If you read the above excerpts more carefully, you will see that I was
referring only to CHARACTER *1 scalars vs. CHARACTER *1 arrays.  I may 
still be wrong, but not, I believe, for the reason you gave.

	-P.
-- 
************************f*u*cn*rd*ths*u*cn*gt*a*gd*jb************************
Peter S. Shenkin, Box 768 Havemeyer Hall, Dept. of Chemistry, Columbia Univ.,
New York, NY  10027;  shenkin@still3.chem.columbia.edu;  (212) 854-5143
***************** Watch this space for an important message ******************
From: ric@updike..sri.com (Richard Steinberger)
Newsgroups: comp.lang.c
Subject: strtol() return values
Date: 25 Jan 93 22:57:03 GMT


	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


Newsgroups: comp.lang.c,comp.lang.c++