HDTenEightyP/NetNews huggingface dataset:
From: richard@crowded-house.den.mmc.com (Richard Armstrong)
Subject: Where are literals stored?
Organization: Martin Marietta
Date: Wed, 18 Nov 1992 23:37:39 GMT

Are literals always stored in the same location in memory? (IBM-PC,Borland)

For instance, is the string a stored in the same place in the following
two declarations?:

static char a[]="ABC"
funca()
{
}

funca()
{
char a[]="ABC";
}


-- 
My company never said any of this... I didn't either.
Richard Armstrong, Software Engineer, Martin Marietta
Email->>>> richard@crowded-house.den.mmc.com <<<<-Email
From: dik@cwi.nl (Dik T. Winter)
Newsgroups: comp.lang.c
Subject: Re: Allowed Fortran and C optimizations
Date: 22 Nov 92 17:07:48 GMT
Organization: CWI, Amsterdam

In article <16019@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
 > Tools like the PORT checker or ToolPack are all but essential.

I agree many people do not use such tools.  But how many people use lint?
It is the cross-module checking that is in many cases not performed.
(And I know of at least one algorithm in Fortran, published in TOMS, that
violates the standard.  But in that case it is not so much the routine
itself that violation, but the combination of the routine description
and the routine itself that might give standard violations.  The
documentation tells us that parameters A and B may be the same while
this is contradicted by the code.)
-- 
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland
home: bovenover 215, 1025 jn  amsterdam, nederland; e-mail: dik@cwi.nl
Newsgroups: comp.lang.c
From: darcy@druid.uucp (D'Arcy J.M. Cain)
Subject: Re: Where are literals stored?
Date: Sat, 21 Nov 1992 14:26:14 GMT
Organization: D'Arcy Cain Consulting

richard@crowded-house.den.mmc.com (Richard Armstrong) writes:
>Are literals always stored in the same location in memory? (IBM-PC,Borland)

There is a switch in the options menu to turn this on and off

>For instance, is the string a stored in the same place in the following
>two declarations?:
>static char a[]="ABC"
> [...]
>char a[]="ABC";

Regardless of whether the compiler merges duplicate literal strings, that
is not what you are talking about here.  These variables are not pointers
to strings but are arrays of characters.  In the first case the array is
filled at compile time and is a unique memory location not shared by other
locations.  In the second case the array is filled at run time and may be
implemented by a form of strcpy() and in that case the actual string copied
may be shared with something else.  However even this is not required.  The
copy in this case could be optimized to an assignment of a long to the
location used by a and so there is no actual string in memory to be shared.

In the following example the strings may be shared (if the proper switches
are set)

static char *a = "ABC";
...
char *a = "ABC";

Of course the variables should probably be declared const in this case.

-- 
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   |
Newsgroups: comp.lang.c
From: bandy@netnews.jhuapl.edu (Mike Bandy)
Subject: Re: Help me track down memory leakage
Organization: JHU/Applied Physics Laboratory
Date: Tue, 17 Nov 1992 16:47:23 GMT

abuhr@owlnet.rice.edu (Aaron M. Buhr) writes:

>     I've inherited a very large C program that I am trying to maintain and
>expand, and I've come to the point where I HAVE to find out where the
>program's leaking memory.  The program starts out with about 7MB virtual
>mem usage, 6MB real, and grows over the course of 6-8 hours to around 20MB
>virtual, 10MB real.  The program uses straight malloc() and realloc() calls.
>I don't know where or how to start trying to track this down.  Any help
>would be greatly appreciated.  Email is preferred, but I'll try to watch
>the posts to this group as well.  Much thanks in advance.

You need to give us a little more info -- specifically, what operating sytem?
If it's VMS I can get you started, if it's something else, I'd just be
wasting everybody's bandwidth...

-- 

	Mike Bandy
	bandy@aplcomm.jhuapl.edu
	Johns Hopkins University / Applied Physics Lab
From: eli@csd4.csd.uwm.edu (Elihu Lubkin)
Newsgroups: comp.lang.c
Subject: confused
Date: 21 Nov 1992 15:02:00 GMT
Organization: University of Wisconsin - Milwaukee
NNTP-Posting-Host: 129.89.7.4

From uwm.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!udecc.engr.udayton.edu!blackbird.afit.af.mil!dsacg3.dsac.dla.mil!dsac.dla.mil!hq.dla.mil!fhi0055 Sat Nov 21 08:08:00 1992
From: fhi0055@hq.dla.mil (Marc Poole)
Newsgroups: comp.lang.c,comp.lang.c++,comp.misc
Subject: Confused
Date: 20 Nov 92 16:07:52 GMT
Followup-To: comp.lang.c,comp.lang.c++,comp.misc
Organization: HQ Defense Logistics Agency/DASC, Cameron Station, VA


 The following is a program that I am trying to write.  I can not seem
 how to get the outer loop to work.  The situation is, the inner loop
 will run until it is finished, when it falls through the program should
 prompt for another int input.  If the user inputs 0 then the whole
 program will end.  If the user inputs any other number, the loop will
 continue. 

 My problem is I can't seem to contruct the outer loop to end once 0 is
 entered.  I either get an endless loop (with wrong answers the 2nd time
 through) or I get no answer after input of first int and the program
 ends.

#include <stdio.h>
main()
{
float answr;
int fact;
int count;



printf ("This program is designed to print the factoral of a number ");
printf ("entered by the user.\n");
printf ("Enter your number: ____\b\b\b\b");

-----------------------------------------------------------------------
|   This will work, although it could be made a lot slicker. trl.
|
|   The outer while needs a stop flag, e.g an int done=0 in declarations;
|   while(!done){
|  ******             scanf ("%d",&fact);  *****Must be in outer while too.
|  **check if done:   if(fact==0)done=1; 
|                     else{
|  *******            count = 1;           ****Must be in outer while,or your
|                                            factorials will be multiplied by
|                                            the previously output ones.
|                     rest of your loop;
|
|                          thelma
------------------------------------------------------------------------------
while 
{
    while (fact > 0)
       {
       count = count * fact--;
       }
answr = count;
printf ("%e", answr);
printf ("\n");
printf ("Enter another number or 0 to quit: ___\b\b\b");
}


printf ("\n");
}

 I left the while statement in the beginning of the outer loop, because
 that's the loop I am trying to use.  It's the coding for that statement
 I can't figure.  Should scanf come after the first while, with it or is
 while not correct at all?

 If anyone can help or steer me in right direction please let me know.

 Hints and not answers would be greatly appreciated, explanations would
 be appreciated aslo.

 mpoole@hq.dla.mil                   |       To some avail

   


Newsgroups: comp.lang.c
From: mcastle@mcs213f.cs.umr.edu (Michael R Castle)
Subject: Re: What is meant by: double A[n,m]?
Date: Thu, 19 Nov 1992 00:21:34 GMT
Organization: University of Missouri - Rolla

In article <1992Nov18.223900.8941@kpc.com> hollasch@kpc.com (Steve Hollasch) writes:
>    A completely contrived example, but it should demonstrate that using a
>comma operator within an array subscript is not meaningless (though some
>might object to the above construct for reasons of style).

So, how many times has this technique been used in the Obfuscated C Contest?

just curious,
mrc
Newsgroups: comp.lang.c
From: dfuller@portal.hq.videocart.com (Dave Fuller)
Subject: Re: fwrite & fread
Organization: VideOcart Inc.
X-Newsreader: Tin 1.1 PL3
Date: Thu, 19 Nov 1992 14:02:13 GMT

U17868@uicvm.uic.edu () writes:
: I am using write & fread to read and write to a file. The structure that I
: am writing has 194 bytes. After executing fwrite I check the value, in vari
: able a which is 1 (correct), because I am writing one structure. Then I check
: the values of returned by fclose and ferror and they are also correct i-e 0.
: But when I quit from the program without writing more structures or without
: running any other functions and look for the size of my file it shows that it
: has 414 bytes. Actually, it should have 194 bytes. I have tried with different
: file modes, but that doesn't solve the problem. I have also tried with a file
: initially empty and with a file having some records. Therefore, I tried clearin
: g the buffer, but that also doesn't help. For those of you who might be interes
: ted in the code, I have it below. Don't pay attention towards syntax errors.

  The problem probably is that you are seeing the file size that the OS has
used up. If the OS writes in block mode instead of char mode it will do
this.

Dave Fuller
dfuller@portal.hq.videocart.com 
Newsgroups: comp.lang.c
From: gordon@osiris.cso.uiuc.edu (John Gordon)
Subject: Re: problem with foef()
Organization: University of Illinois at Urbana
Date: Sun, 15 Nov 1992 17:30:16 GMT


	The problem is that feof() cannot predict EOF.  EOF will only occur
when the file pointer is at the end of the file, and another read is
attempted.

---
John Gordon                        My incredibly witty saying has been 
gordon@osiris.cso.uiuc.edu         Politically Corrected into oblivion.
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c
Subject: Re: Can you program in C?
Date: 19 Nov 92 07:10:29 GMT
Organization: Comp Sci, RMIT, Melbourne, Australia

In article <00963BF4.675CEA80@vms.csd.mu.edu>, 2644danticoj@vms.csd.mu.edu writes:
> My name is Cetera and I am new to this network.

Clearly.  It is considered bad manners to ask other people to solve your
homework problems.  Have you read news.announce.newusers?

> However, all homework is programmed in C and because of an adminstrative
> loop-hole, I was enrolled in the class with no knowledge of the needed
> programming language.

I have been on the other end of this problem.  Your administration deserve
a rebuke for the loophole, and you deserve a rebuke for exploiting it.  Few
lecturers add prerequisites to the course just for the heck of it.

> So, can you help me write these programs, thereby
> allowing me to graduate and go on to serve my country as an officer on a
> nuclear submarine?

I come from a country which was illegally expelled from ANZUS because we
didn't want those things around.  I studied in a country, which, although
an ally of the dominant ANZUS partner, was nervously aware that some of
said colossus's missiles were aimed our way.

And you want we should _help_ someone cheat onto a nuclear sub?  _My_
future may depend on your country's having honest officers.

Look in a textbook.  Try Sedgewick's "Algorithm's in C."  There are many
others.  While you're at it, buy a book on C and study it.  "A Book on C"
seems to be pretty good.
Newsgroups: comp.lang.c
From: wai@csuvax1.csu.murdoch.edu.au (Julian Wai)
Subject: Unhandled exception error from BC++3.1
Organization: Murdoch University
Date: 22 Nov 92 11:59:23 GMT

Hi,

Does anyone know what the following error mean ?  Any suggestions will be
appreciated.


----------------------------------------------------------------------------

        UNHANDLED EXCEPTION 0D at 00B7:229A Error code: 034C

         AX = 000D   BX = 0000   CX = 0148   DX = 0050
         SI = 0057   DI = 0045   BP = 0FE2   SP = 0FDA
         CS = 00B7   Limit =240F
         DS = 00BF   Limit =219F
         ES = 00BF   Limit =219F
         SS = 005B   Invalid segment
         - 00B7:2292   3D 1E 06 2E 8E 1E 05 00  FF 1E 87 21 07 1F 5F CF

         You may hit [T] to terminate, but you should reboot as soon as possible,
         as the system is unstable ...t
         Unhandled exception 000D at 00B7 229A ErrCode 034C  



Thanks in advance.

Julian
wai@csuvax1.csu.murdoch.edu.au 
Newsgroups: comp.lang.c
From: isc40038@nusunix1.nus.sg (LIM FANG HOW)
Subject: How to extract file descriptor
Organization: National University of Singapore
X-Newsreader: TIN [version 1.1 PL6]
Date: Sat, 21 Nov 1992 06:51:13 GMT

I am trying to lock a file which is open using fopen. As what I know,
fopen returns a file pointer which points to a structure that contains
information about the file.But the flock function only takes a file
descriptor and not a file pointer.

Qn1 : Does the structure pointed by file pointer contains the file
      descriptor ? I could not find the file descriptor in the stdio.h
      in my system (SUN sparc using 4.3BSD)

Qn2 : If yes, how to extract it from the structure ?
      I tried the following and it returns fd not defined :

               FILE *fp;
                   :
                   :
               fp=fopen("A","r");
                   :
                   :
               fdes=fp->fd;

Qn3 : Is there any way to lock a file using the file pointer instead of
      file descriptor ?

P.S : fopen is preferred because it supports fscanf and fprintf and not
      read or write.

Newsgroups: comp.lang.c,comp.std.c
From: wilson@rhombus.cs.jhu.edu (Dwight Wilson)
Subject: Re: Idle Questions about ANSI C
Followup-To: comp.std.c
Organization: The Johns Hopkins University CS Department
Date: Tue, 17 Nov 1992 20:53:44 GMT


In article <1992Nov17.155826.15087@sq.sq.com> msb@sq.sq.com (Mark Brader) writes:
>> > According to K+R 2nd ed, section A7.4.8, size_t is "an unsigned
>> > integral constant; the particular type in implementation defined".
>> 
>> Well, the result of sizeof is the quoted thing, and it notes that
>> <stddef.h> defines the type in question as size_t.
>> 
>> Now: is it required that size_t be the same as one of the four usual
>> unsigned integral types?  (How about ptrdiff_t?)
>
>The wording of section 3.1.2.5/6.1.2.5 of the standard clearly implies
>that the 9 "usual" integral types are the only ones.  They consist of
>4 signed integer types, 4 unsigned integer types, and char -- which
>of course can be either signed or unsigned.  Since size_t and ptrdiff_t
>are specified respectively as unsigned or signed *integral* types, not
>*integer* types, then an implementation could actually use char for
>one of them -- remember, it could be the same size as int or even long.
>So there are 5 possibilities for each.

To get nitpicky, section 3.3.3.4 states that size_t is an
unsigned integral type.  Section 3.1.2.5 discusses the integral
types.  As I read it, no matter what its implementation, char is 
neither an unsigned integral type nor a signed integral type.  Thus,
there are 4 possibilites for size_t and ptrdiff_t.

-Dwight
From: forb0004@student.tc.umn.edu (Eric Forbis)
Newsgroups: comp.lang.c
Subject: Re: MSDOS C Compiler advice?
Date: 19 Nov 92 03:38:51 GMT
Article-I.D.: student.forb0004.83.722144331
Organization: University of Minnesota

In article <1992Nov17.070519.6080@eagercon.com> eager@eagercon.com (Michael J. Eager) writes:
>In article 721891955@student.tc.umn.edu, forb0004@student.tc.umn.edu (Eric Forbis) writes:
>
>>I noticed that MS C users can upgrade to the SDK for a mere $139; extremely 
>>tempting for a cash-strapped married student. However, I've heard that the 
>>SDK is a time- consuming pain to learn. I haven't heard much about Borland's 
>>frameworks, and assume you've got to dish out the $400; no upgrade. I won't 
>>be doing any Windows programming for some time to come, of course, but 
>>would like to look ahead a bit to avoid rebuying the wheel.
>
>The SDK and Borland Framework are both for Windows programming.  SDK is complex
>and detailed.  Neither is something that a brand new C programmer should 
>purchase just to have.  If you buy it now, chances are that you will end up
>buying an upgrade by the time you have enough experience with C to use either.

The inevitable upgrade problem hadn't occurred to me; think I'll stick with 
Borland Turbo C. You're right, it'll be awhile before I even consider 
looking at Windows programming. 

This is an uncommonly considerate newsgroup; 10 people have kindly sent e-
mail advice, and not a flame or nasty note amoung them! I expected at least 
a few well- deserved cutting criticisms about my willingness to rely on 
pretty interfaces, something I almost immediately regretted posting.

Thanks much!


>
>>
>>The only difference I'm aware of is that Borland is said to compile a little 
>>faster and sparely. I'm won't have a lot of time to spend on the compiler 
>>itself, so any pretty point and run features would be welcome. 
>
>If you can't program in C yet, compilation speed is not important :-).
>
>Any, absolutely any compiler will be adequately fast for a course in C programming.
>Time spent in compilation will not be significant in learning C, and usually
>is not significant until you are working on files with hundreds or thousands
>of lines of code, or compiling a significant number of files at a time.
>
>Think of it this way, if compiler A compiles your program in seven seconds, 
>how much more productive will you be if compiler B compiles it in five?
>
>>
>>BTW, is it true that there's no direct way to read and write disk volume 
>>labels in C? How do you get around this; is assembly required?
>
>No it is not true.  Look in the library manual for BIOS calls which will
>read disk records.
>
>
>---
>Michael J. Eager		Michael.Eager@eagercon.com
>Eager Consulting		(415) 325-8077 
>1960 Park Boulevard, Palo Alto, CA 94306-1141
>
---------

Eric Forbis      forb0004@student.tc.umn.edu
Newsgroups: comp.lang.c
From: rs@cbnewsm.cb.att.com (robert.w.sanderman)
Subject: can't access a needed shared library
Organization: AT&T
Distribution: att
Date: Fri, 20 Nov 1992 20:43:06 GMT

I am trying to move our copy of the S language package from a 6386 running
Unix 3.2.2 to an NCR 3550 running System 5 release 4.  When I try to run
the program I get the error message:

can't access a needed shared library

Is there any kind of work-around to this problem?  AT&T no longer supports
the software.

Thanks
Bob Sanderman
rs@homxb.att.com
Newsgroups: comp.lang.c
From: perry@bobcat.lmc.edu (James Braxton Perry, II)
Subject: Any IO libraries out there?
Keywords: C, IO
Organization: Lees-McRae College, Banner Elk, NC
Date: Wed, 18 Nov 1992 19:10:46 GMT

Hello, I am wondering if there are any good ftp sites for public domain C 
algorithms. I checked the FAQ and couldn't find a FAQ listing.

If you have any interesting basic IO routines that simplify programming in C 
and do not care if you share them, they would be greatly accepted. 

I ask because being a pascal (no flames please) programmer I could find 
Turbo Pascal units that made my programming endeavors much easier.

You could also e mail at the address below.
And, no I am not taking a C class at the present. 
I am a Math Major learning C in my spare time.

Thank you,
James B. Perry, II
Newsgroups: comp.lang.c
From: dkeisen@leland.Stanford.EDU (Dave Eisen)
Subject: Re: Multiple &'s in an if statement
Organization: Sequoia Peripherals, Inc.
Distribution: comp.lang.c
Date: Mon, 23 Nov 92 21:29:24 GMT

In article <kf4GU6q00VQsM3GGYU@andrew.cmu.edu> rickr+@CMU.EDU (Richard Dale Romero) writes:
>Probably because you're using bit-wise and instead of logical and.
>In C, a zero is false and anything else is true.  There is no specification

False. 

All of the boolean operators (==, &&, and ||) are guaranteed to
return 0 for false and 1 for true. There are obfuscated C contest
entries that depend upon this behavior so the ANSI committee couldn't
change that.



-- 
Dave Eisen                               Sequoia Peripherals: (415) 967-5644
dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
       There's something in my library to offend everybody. 
          --- Washington Coalition Against Censorship
Newsgroups: comp.lang.c
From: jlnance@eos.ncsu.edu (JAMES LEWIS NANCE)
Subject: Re: Is this ANSI?
Originator: jlnance@chow2.ece.ncsu.edu
Reply-To: jlnance@eos.ncsu.edu (JAMES LEWIS NANCE)
Organization: North Carolina State University, Project Eos
Date: Mon, 23 Nov 1992 18:08:08 GMT


In article <By6HMs.I4r@unx.sas.com>, sasghm@theseus.unx.sas.com (Gary Merrill) writes:
|> 
|> |> 
|> |> > I think "does not allow that technique" is a little strong.  What you
|> |> > *can* do is
|> |> 
|> |> 	struct FM
|> |> 	{
|> |> 	   short data_len;
|> |> 	   char  data[1];
|> |>         };
|> |> 
|> |> 	struct FM *fmptr;
|> |> 
|> |> 	fmptr = malloc( sizeof(struct FM) + ??? );
|> |> 

I asked my C mentor about this once, and he pointed out that the compiler is
free to store the members of the structure in any order.  Thus the compiler 
could store data[1] in memory before it stores data_len.  Then if you wrote
to data[1] you would clobber data_len.  I got around this by something like
this:

struct FM {
     short datalen;
     char  *data;
     }

struct FM *fmptr;

fmptr = malloc(sizeof(struct FM) + ??? + 1);  /* +1 only if you need null term*/
fmptr->data = (char*) (fmptr+1);

This will work regardless of the ordering of the structure members.


Jim Nance
Newsgroups: comp.lang.c,comp.lang.pascal
From: cs202144@umbc8.umbc.edu (cs202144)
Subject: Re: C to Pascal, Pascal to C?
Organization: University of Maryland, Baltimore County Campus
Date: Sun, 22 Nov 1992 22:44:32 GMT

> Try archie-- I know i have heard of "c2p" being the name...

I would love to have one of these...If anyone knows for sure where I can get
one please send me the entire ftp address. A Pascal to C makes more sense
since there are C features that Pascal cannot do or rather probably cannot do
easily like unions, double and short data types, etc. Whereas everything Pascal
can do C has some analog.
Newsgroups: comp.lang.c
Subject: How to use another library?
From: <SATCC@CUNYVM.BITNET>
Date: Wednesday, 18 Nov 1992 15:50:35 EST
Organization: City University of New York/ University Computer Center

I am new to C and am using Turbo C++ 3.0.  Recently I got a library of
functions (*.LIB) and have placed it in my library directory (i.e. C:\TC\LIB).
However whenever I compile my program using these functions, I get an error
message saying that the function couldn't be found.  Is there something I am
doing wrong??  I would like to run the program from the IDE for easier
debugging.  I have looked into the manual but to no avail.

Please reply me directly,

Thanks in advance,

Sameer.
Newsgroups: comp.lang.c