HDTenEightyP/NetNews huggingface dataset:
Nf-ID: #R:<cee1:713424953:inmet:20900024:000:1740
Nf-From: inmet.camb.inmet.com!richw    Aug 12 10:48:00 1992


>>  char *foo = "abc";
>>  char *foo[] = "abc";
>>  char foo[] = "abc";
>>  char foo[4] = "abc";

First, let me give these "foo"s unique names:

    char *fooA = "abc";
    char *fooB[] = "abc";
    char fooC[] = "abc";
    char fooD[4] = "abc";

Here's a way of rewriting these which might make things clearer:

    static char literal [] = { 'a', 'b', 'c', '\0' };

    /*  "literal" is now a constant which equals the address  */
    /*  of the first element of an initialized, 4-element     */
    /*  "char" array					      */

    char *fooA = literal;
    char *fooB[] = (char **) literal;
    #define fooC literal
    #define fooD literal

Thus, "fooC" and "fooD" are identical; both are constants which equal the
address of the "literal" array's first element.

"fooA", on the other hand, is an initialized variable which can be re-
assigned, i.e. the following are legal:

	char *ptr;

	fooA = "some other literal";
	fooA = ptr;

but this isn't:

	fooC = "some other literal";

Note that the "4" in the "char fooD[4]" declaration is entirely unnecessary;
what's interesting are these cases:

	fooD[3] = "abc";	/*  Illegal !  "fooD" is too small  */

	fooD[5] = "abc";	/*  "fooD" is the constant address  */
				/*  of the first element of a 5-    */
				/*  element "char" array whose 5-th */
				/*  element is uninitialized	    */

Finally, note that "char *fooB[]" represents a pointer to an array, where
each element of the array is itself a pointer to "char".  This is a
*different* type than the type of "abc", i.e. a pointer to "char".  I'm
surprised my C compiler accepted for "fooB" declaration.  In any case,
I would never write such a declaration...


Rich Wagner
    Intermetrics, Inc.
    richw@inmet.camb.inmet.com


Newsgroups: comp.lang.c
From: R2NVK@VM1.CC.UAKRON.EDU
Subject: schematic capture programs in c
Organization: The University of Akron
Date: Fri, 21 Aug 1992 20:47:05 GMT

I wanted to know if there are any schematic capture programs available in C.
thanking you in advance.
                        nagesh
 
 
Newsgroups: comp.lang.c
From: nilo@atdigarfield.cern.ch (Nilo Segura)
Subject: Re: problems with atof()
Reply-To: nilo@atdigarfield.cern.ch
Organization: CERN. European Center for Nuclear Research
Date: Fri, 21 Aug 1992 00:28:11 GMT

Yep!  the correct answer was to include <stdlib.h>, atof() is declared there ( at least in 
the vax/vms C-libraries )

    thank you for your help.

---
** Nilo Segura                         phone (41) (22) 7674372
** Database Support for Engineering    e-mail nilo@atdigarfield.cern.ch
** Accelerator Technology Division            nilo@cernvm.cern.ch
** CERN
** Geneva - Switzerland

Newsgroups: comp.lang.c
From: fin@unet.umn.edu (Craig A. Finseth)
Subject: Re: why does #define Ctrl(c) c&037 work ?
Organization: University of Minnesota, Networking Services.
Distribution: worrrld
Date: Mon, 17 Aug 1992 14:31:56 GMT

In article <1992Aug16.224049.23485@zooid.guild.org>, Ross Ridge <ross@zooid.guild.org> writes:
|> fin@unet.umn.edu (Craig A. Finseth) writes:
|> >The "correct" macro should be:
|> >#define Ctl(c) ((c)^'@')
|> >Which works for all of the above, and ? too.

|> The macro is pretty bogus to begin with.  It only exists because
|> it used to be:
|> 	#define Ctl(c) ('c'&037)
|> While unportable and just as bogus, it was at least convienent.  eg:
|> 	char eof = Ctl(D);
|> Otherwise you might as well just do:
|> 	#define CTL_A	'\001'
|> 	...
|> 	#define ESC	'\033'
|> 	...

Except, of course, if you are trying to do:

	int x = 'A';
	int y;

	y = Ctl(x);

Craig
From: wsanders@ffeine.Sun.COM (Wiley Sanders)
Newsgroups: comp.lang.c
Subject: Re: POWER OF LARGE NUMBERS
Date: 19 Aug 92 15:38:38 GMT
Organization: Tradeshow Tech Support
NNTP-Posting-Host: ffeine.corp.sun.com

Just out of curiosity, what kind of problen requires that you
know the value of such a very large number, rather than its
logarithm, or only the difference between it and another very
large number of the same magnitude?
-wiley
--
"What a waste it is to lose one's mind, or not to
have a mind as being wasteful. How true that is."     -Dan Quayle
Newsgroups: comp.lang.c
From: fardad@bostech.com (Fardad Farahmand)
Subject: Fortran to C translator
Organization: Boston Technology, Wakefield, MA
Date: Wed, 12 Aug 92 20:53:07 GMT




I need a utility to convert FORTRAN source to C.  I hope to find it
for free, but will pay a small fee if necessary.

If I can't find this anywhere I'll have to learn FORTRAN again and
convert this rather large set of routines by hand.  

Please email me your comment since I don't normaly read this
newsgroup.

Thanks
FF

fardad@bostech.com
Newsgroups: comp.lang.c
From: wkaufman@us.oracle.com (William Kaufman)
Subject: Re: qsort problem....
Organization: Oracle Corporation, Redwood Shores CA
Date: Sat, 15 Aug 1992 05:07:35 GMT
X-Disclaimer: This message was written by an unauthenticated user
              at Oracle Corporation.  The opinions expressed are those
              of the user and not necessarily those of Oracle.

    David's mostly right about qsort()--his fixes work.  But,...

In article <1992Aug14.133320.28769@bohra.cpg.oz.au> daavid@bohra.cpg.oz.au (Daavid Turnbull) writes:
] 
] This at first feels like a clumbsy solution but you get passed that.
] The thing that pisses me off is that the most readable version of
] the solution, (IMHO the one I have presented) creates two extra variables,
] which are a complete waste of data.

    Well, they *aren't* a waste of data.  Let's say that (myfloat *) and
(void *) are different on your machine--maybe they're of different
sizes, maybe the representation is different.  When qsort calls back
your function with a couple of (void *)'s and you try to use them as
(myfloat *)'s, your program will most likely crash.

    And, this isn't an obscure theoretical machine that has pointers
like this: there are real live machines that do this, and you (generic
you) may find yourself working on one.  (Yes, not all the world's a
Sun,...)

    (Grumble, grumble,... you don't know "pissed off" until you've had
to port code from someone who thought you could cast an array of
pointers,... grumble grumble,...)

] int qs_compare(const	void *a,  const	void *b)
] {
]     if ((my_double *a)->f < (my_double *b)->f)
parens     ^          ^        ^          ^
]        return (-1);
]     else if ((my_double *a)->f == (my_double *b)->f)
parens          ^          ^        ^           ^
]        return (0);
]     else
]        return (1);
] }

    Yes, this will work, too, even on machines with pointers that don't
exist on a Sun.

] Thats ansi for you,

    Well, it's good portable programming, anyway,...

                                           -- Bill K.

Bill Kaufman,          | "Hush my darling / Be still my darling /
Corporate Lackey       |  The lion's on the phone,..."
wkaufman@us.oracle.com |              -- "The Guitar", They Might Be Giants
Newsgroups: comp.lang.c
From: davis@pacific.mps.ohio-state.edu ("John E. Davis")
Subject: Paranoia, side effects, and optimizing compilers
Reply-To: davis@pacific.mps.ohio-state.edu  (John E. Davis)
Organization: "Dept. of Physics, The Ohio State University"
Date: Fri, 14 Aug 1992 17:00:03 GMT

Hi,

   Consider:

      unsigned char *p;   
   
      while (1)
        {
           p = CLine->data + Point;
           if (*p > ' ') break;
           del();
        }

Here CLine->data is a pointer of same type as p and Point is an integer.
del() is a routine that has that might possibly do a realloc on
CLine->data so p might change in the loop.

Would an optimizing compiler asssume that p will not change in the loop,
evaluate it once and assume it is fixed in the loop?  In this case, I would
want to declare it as volatile but I'd rather not worry about these issues.
Or should I?


    
--
     _____________
#___/John E. Davis\_________________________________________________________
#
# internet: davis@amy.tch.harvard.edu
#   bitnet: davis@ohstpy
#   office: 617-735-6746
#
From: dchek@Bonnie.ICS.UCI.EDU
Subject: test message
Newsgroups: comp.lang.c
Date: 21 Aug 92 08:21:25 GMT

Please ignore this message...
From: bcschu@skws02.monsanto.com (Brett Schultz)
Newsgroups: comp.lang.c
Subject: Re: Convert float to a string ?
Date: 20 Aug 92 17:21:12 GMT
Organization: Monsanto Company

prem@prem.lbl.gov (Shirdi R. Prem) writes:
: In article <1992Aug19.204417.13500@tin.monsanto.com> bcschu@skws02.monsanto.com (Brett Schultz) writes:
: >KSZ@VM.NRC.CA writes:
: >: Suppose I have a float a=12.4567, how can I convert it into a string including
: >: 8 characters? i.e. What I want is
: >
: >Use sprintf..
: >
: >main()
: >{
: >   float a = 12.4567;
: >   char b[10];
: >
: >   sprintf(b,"%f\0",a);
: >}
: >That'll do it.
: >Brett
: 
: 
: 	   sprintf(b,"%f\0",a);
: 		     ^^^^^^
: 		     ^^^^^^
: 
: 	Are you sure you need a '\0' here............???
: 
: 	Prem!  (I guess I should've written a test program to find out, )   
: 	       ( rather than posting this..........                     )


No, I'm not sure if one NEEDS a \0 there, but it surely doesn't hurt to put
one there, now you KNOW that your string is null terminated.

Let me know if sprintf puts one there anyway, I wasn't sure.

Brett
Newsgroups: comp.lang.c
From: davisonj@bnr.ca (John Davison)
Subject: Re: spin the wheel
Followup-To: alt.flame
Summary: you are confused
Organization: Bell-Northern Research, Richardson, Tx.
Distribution: usa
Date: Mon, 17 Aug 1992 19:42:57 GMT

In article <92230.132615U56779@uicvm.uic.edu> U56779@uicvm.uic.edu writes:
>Can anybody tell me a code in c to spin the wheel after drawing it.
>thanks...

        This should do the job, assuming that the_wheel is a global variable:

{
    spin_wheel();
}

-- 
NOTE: I CAN'T SEND/RECEIVE E-MAIL HERE!!!  Use --> davisonj@ecn.purdue.edu <--
      During (roughly) August 20-25, I will be in transit.  Please be patient.
      The opinions and other information contained herein are not necessarily
      representative of Northern Telecom or any of its subsidiaries. 
Xref: sparky comp.lang.c:12616 comp.std.c:2488
From: pinkas@caraway.intel.com (Israel Pinkas)
Newsgroups: comp.lang.c,comp.std.c
Subject: scrcpy implementation question
Date: 21 Aug 92 19:45:08 GMT
Distribution: comp
Organization: Software Technologies, INTeL Corporation, Santa Clara, CA


A compiler group working for us has told us that they plan to make the
following optimization for the strcpy library function:

If the sizes of the src and dst are known at compile time (e.g. they are
both declared in the current file as static or auto arrays), and if the
addresses are aligned correctly, then strcpy will be inlined as a partially
unrolled loop of word moves.  In order to avoid checking every byte, they
plan to copy past the terminator ('\0'), and copy a number of bytes equal
to the smaller of the src or dst.

They have data showing that the extra copying performs better than having
to test every byte, but I am concered that there might be a lot of code
that will break.  For example, I can see an implementation of
getcwd()/getwd() which have to walk the directory tree back to /.  Find the
name of the current directory by finding the entry in .. which has the same
inode as .  Put the name at the end of a buffer.  When the routine gets the
name of .., prefix it by copying it in to the buffer immediately before
what is already there.


Does anybody know if strcpy is allowed to copy past the end of the string?
We looked at K&R2 and at the ANSI spec, but were unable to find anything
definite.

-Israel Pinkas
 pinkas@stps18.intel.com

--
Disclaimer: The above are my personal opinions, and in no way represent
the opinions of Intel Corporation.  In no way should the above be taken
to be a statement of Intel.
Newsgroups: comp.lang.c
From: amorgan@Xenon.Stanford.EDU (Crunchy Frog)
Subject: Re: Optimizing code for tests
Organization: Computer Science Department, Stanford University.
Date: Fri, 14 Aug 1992 20:05:53 GMT

In article <1992Aug14.192350.4786@tin.monsanto.com> bcschu@skws02.monsanto.com (Brett Schultz) writes:
>
>Many of you have also suggested to look for bottlenecks in my program.
>I appreciate the info, but I have already found the bottlenecks and just
>thought that optimized code runs faster than non-optimized code (esp. when
>compiled with debugging info).  

Hold on, are you compiling with debugging on?  Most compilers (GCC being
one of the few exceptions) do not do optimization and debugging at the
same time.  Is this your problem?

I am not sure what the -j option does, but if the manual says to
use it, use it :-).
  
>Brett

C Frog
Newsgroups: comp.lang.c
From: jes@grendel.demon.co.uk (Jim Segrave)
Distribution: world
Subject: Re: using TURBO C with inline assembly
X-Mailer: cppnews $Revision: 1.14 $
Organization: None
Date: Wed, 19 Aug 1992 22:12:44 +0000


In article <1992Aug19.081758.4551@trl.oz.au> s.mathers@trl.oz.au writes:

> 
> Hello, I am in need of help from someone familiar with the way
> Turbo C++ handles inline assembly.
> 
> My problem is that I would like to be able to issue an
> OUT ax,dx from inline assembly.  Currently I am using the 
> OUTPORT command, which works fine, but generates a lot of needless
> assembly instructions...something like 16 instructions, as opposed to
> the 3 I would need for the OUT assembler command.
> 
> What I would like to know is:  Can I freely use AX and DX in an inline
> assembly, without having to worry if Turbo was expecting the values of
> these registers to be anything in particular, and thus throw things out
> of kilter.  I tried it, and it worked fine, but I'm not sure if I was
> just lucky, and I am reluctant to continue with this method unless I know it
> will be A-OK.
> 
> Thanks for any replies.
I've used inline assembly quite heavily in BIOS programming using TC++ 1.01.
The first thing I noticed is that outp () and inp () generally result in
direct emission of the code rather than function calls, so usually
there's little profit in inline assembly for these if the port address  or
value to be output is derived from the C code itself, since you will have
to arrange to load the registers first - eg.
_DX = foo;
_AL = bar;
asm out dx,al;
On the other hand, if the values are constants, then it might pay (but not
much). TC seems to register the use of inline assembly and direct
register assignments, so it reloads any values it thought would be in
there. I've never had it go wrong in that sense. It can get very
convoluted to ensure that you get the correct values into the registers
in the first place, since array referencing may use ax or dx - for example
to output foo[x] to port bar:
_DX = bar;
_AX = foo[x];
asm out dx,al;
may clobber dx while loading ax. Only hand checking of the result can
catch these. You can do quite well by using inline assembly (I mostly
needed to ensure function calls passed things in registers because I had
to restrict stack usage, or sometimes I needed hand-tuned code for speed
or space, but all in all I've slowly been migrating a lot of it back to
assembler - the headaches of hand checking got to be a bit much).

--
Jim Segrave (Segrave Software Services)     jes@grendel.demon.co.uk

Newsgroups: comp.lang.c
From: jogulin@camelot.fia.dmg.ml.com (Joseph Ogulin)
Subject: Re: Computer terms, etc
Organization: The Rift from Here to There
Date: Tue, 11 Aug 1992 12:21:17 GMT

In article <cee1.713424953@Isis.MsState.Edu>, cee1@ra.msstate.edu (Charles Evans) writes:
|> If anyone could help me, please define these for me:
|> and what is the diff. between  *foo[] and **foo?

I haven't experienced one, but *foo[] is an array of character pointers
and **foo is a pointer to a character pointer.

|> whats the diff in these?
|> 
|> char *foo = "abc";
|> char *foo[] = "abc";

What you have as *foo[] = "abc"; is an illegal declaration.  You would have
to declare it as follows:

	char *foo[] = { "abc", 0 };

because you are declaring an array of pointers.  I can't recall if the 0 is
necessary in there (somebody help, I don't do those declarations normally).

|> char foo[] = "abc";
|> char foo[4] = "abc";  <--- is the '\0' autmatcially added?

Yes, the '\0' is automatically added, and there is nothing wrong with that
declaration, however, it is not good practice because what happens when you
want to change the string?  You have to be sure to change the size of the
character array too.

-- 
==> "You never f**king know the answer when it's important." --The Doctor <==
Joe Ogulin

jogulin@camelot.fia.dmg.ml.com		joe@monroe.pilot.dmg.ml.com
jogulin@apollo.stevens-tech.edu		gcs_jogulin@stevens.bitnet

Disclaimer:  The above article is solely my opinion and does not necessar-
ily reflect that of my employer.  The content is my responsibility alone.
Organization: University of Illinois at Chicago
Date: Friday, 21 Aug 1992 11:46:05 CDT
From: <U37956@uicvm.uic.edu>
Newsgroups: comp.lang.c
Subject:  Large memory problem

I am using Ms C 6.0 on DOS5.0 . I have 4MB extented memory.
The following C code is causing me trouble:

#include <stdio.h>
main()
 int i;
  unsigned char *buffer;

  buffer=(unsigned char*)malloc(480000);
  for(i=0; i<480000; i++)
   
       buffer[i]= i%256;
       printf("%u\n", buffer[i]);
   




 It is compiled in large(or huge) memory model:

     cl /AL myprog.c

When I run the program, it prints out the numbers, but in the end, it
gives message" memory allocation error, Can't load COMMAND, the system
halted.", and then the system dies.

What's wrong ?

Any help will be appreciated.

U37956@uicvm.uic.edu
Newsgroups: comp.lang.c
From: linden@positive.Eng.Sun.COM (Peter van der Linden)
Newsgroups: comp.lang.c
Subject: Re: Pointer/address reluctance
Date: 18 Aug 1992 21:20:47 GMT
Organization: Sun Microsystems, Mt. View, Ca.
NNTP-Posting-Host: positive

From: goudreau@batman.rtp.dg.com (Bob Goudreau)
> Beg your pardon?  I can find no definition of a thing called "address"
> in the standard. 

Check out section 3.4, page 56, line 32.

It defines an address constant.  You can't have a <baz> constant unless 
you have <baz>, now can you?  Also check out line 35 in the same section,
which refers to "the address & and indirection * unary operators".

No, the concept of "address" is in the standard, so it seems somewhat
tendentious to shun it.

--
linden@eng.sun.com|| P. van der Linden and his uncustomary theories.
Go Giants!! Don't || When solving a "panic" you must first ask yourself what you
stop at Florida...|| were doing that could possibly frighten an operating system
Newsgroups: comp.lang.c
From: drice@ponder.csci.unt.edu (Keith Rice)
Subject: Re: Linker Error: Segment _TEXT exceeds 64K 
Organization: University of North Texas
Date: Sat, 22 Aug 1992 00:36:39 GMT

In <714426233snx@rcsl.demon.co.uk> tim@rcsl.demon.co.uk (Tim Frost) writes:

>In article <drice.714378305@ponder> drice@ponder.csci.unt.edu writes:

>>
>>In <1992Aug21.010511.15329@cc.umontreal.ca> desmarai@ERE.UMontreal.CA> (Desmarais Normand) writes:
>>
>>>"Linker Error:  Segment _TEXT exceeds 64K"
>>
>>Try compiling it with a COMPACT memory model.
>>

>No!  Compact gives you the same 64k limit for code (TEXT) as does the default
>small model.  You need Medium or Large model to get past this limit.  

>Read the section in the programmer's guide about memory models for more info.

OOPS!!!  I did mean medium!  Honest!  (Oh, I'm sooooo ashamed!)

I repent in dust and ashes.

--
Keith
drice@ponder.csci.unt.edu
From: pom@anke.imsd.uni-mainz.DE (Prof. Dr. Klaus Pommerening)
Subject: Re: POWER OF LARGE NUMBERS
Organization: Johannes Gutenberg Universitaet Mainz
Date: Thu, 13 Aug 1992 10:36:30 GMT

In article <1992Aug12.135106.12924@cs.uow.edu.au> u8705957@cs.uow.edu.au  
(Hitesh Sanghvi) writes:
> Hello there;
> 	Does any one know how to raise power of possibly 100 digits 
> to possibly 100 digits. Any algorithm or code will be appriciated.
> Example
> (1234367463746464647464...up to 100 digit)**(647254627463048736...up to 100  
digit)

First of all you need routines for doing big number calculation, e.g.
GNU-mp. Then you need a book on algorithms that explain the binary
method of exponentiation, e.g. KNUTH, The Art of Computer Programming,
Vol. 2 (see the section 'Evaluation of powers').
--
Prof. Dr. Klaus Pommerening                                                     
Institut fuer Medizinische Statistik und Dokumentation                          
der Johannes-Gutenberg-Universitaet                                             
Obere Zahlbacher Strasse 69, W-6500 Mainz
From: wsh8z@kelvin.seas.Virginia.EDU (William Scott Heyman)
Newsgroups: comp.lang.c
Subject: Another scanf question
Date: 13 Aug 92 18:02:41 GMT
Organization: University of Virginia

I have a list of numbers in a file writen using 
	printf("%f %f\n",a,b); 
many times.
I want to read this list a line at a time using scanf:
	scanf("%f %f\n",&a,&b);
The result is a = b = 0.0 which isn't correct.
I also tried fscanf(stdin,"%f %f\n",&a &b);
to no avail...

Could someone suggest a way to read in this list of numbers?
Thanks

	Will Heyman
	UVA Applied Math
	wsh8z@virginia.edu
From: gonzalod@amex-trs.com (Gonzalo Diethelm)
Newsgroups: comp.lang.c
Subject: Generic sorting functions
Date: 21 Aug 92 21:51:01 GMT



Distribution: world

Hello everyone,

A very generic question. Given a set S of n strings (the `|' characters
are used as delimiters):

  s1   |dunno|
  s2   |I'd rather have a bottle in front of me than a frontal lobotomy|
  s3   |eschew clever rules|
  ... ...
  sn   |bzzzzt!|

and an ordering sequence O:

  {s4, s1, s6, s2, sn, s3, ... s7}

is there any way to determine a fixed, hopefully cheap function

  f(): SxS -> integers

with the property that

  if si comes before sj in O, f(si, sj) < 0
  if si comes after  sj in O, f(si, sj) > 0

that is, could be used to sort the strings in the given sequence?
For example, if the desired sequence happens to be the alphabetical
descending ordering of the strings, f() could just be

  f = -1 * strcmp(si, sj);

My intuiton tells me this is possible, but I don't really know how
to approach the problem. Any help is welcome. Please send answers
and flames via e-mail. Thanks in advance and kindest regards.

gonzalod@amexphx.amex-trs.com
Gonzalo A. Diethelm                 (602)375-8410  home
16220 N 7th St Ap 1314              (602)492-3536  office
Phoenix, AZ 85022                   (602)492-4248  FAX
Newsgroups: comp.lang.c