HDTenEightyP/NetNews huggingface dataset:
From: pihlab@hhcs.gov.au
Newsgroups: comp.lang.c
Subject: Re: Initializing Random Seeds 
Date: 7 Sep 92 10:41:59 +1000
Organization: Aust. Dept. Health, Housing and Community Services

In article <1992Sep4.173259.12437@maccs.dcss.mcmaster.ca>, rickan@maccs.dcss.mcmaster.ca (Mark Rickan) writes:
> Please excuse me if this is a FAQ, but is there a ANSI-compliant means
> of initializing a random seed which has a reasonably low probability
> of recurring? At the moment, I'm using srand in conjunction with
> time(&t). Unfortunately, on a fast machine, the time delay is often
> < 1 second, resulting in the production of the same random value.
> 
> I've avoided this problem by use of a time delay, but I'm convinced
> that there must be a more elegant and efficient means of doing this.
> 
> Any suggestions would be appreciated,

I don't write in C but it sounds like you want a random number as a seed.

One way would be to use a random number as part of your seed determination.

Set your MasterSeed1 to some constant value like 123456 or set it based on the
time when they first log on.

Everytime that you want a new seed:

  1. use your current time sample method to get the time or whatever as a
     SlaveSeed1.

  2. use MasterSeed1 to calculate SlaveSeed2.

  3. set MasterSeed1 to value of SlaveSeed2 for next cycle.

  4. Apply some function to SlaveSeed1 and SlaveSeed2 to give SEED.

  5. Use SEED to generate your RANDOM NUMBERS.
     
The function in step 4 could be ADD, MULTIPLY, SUBTRACT, OR, AND, XOR or
whatever works for you.  (Interested in seeing your final implementation)

If that still gives you numbers close together or closely related to the
MasterSeed sequence then simply factor in MasterSeed2 and alternate between
using MasterSeed1 and MasterSeed2 etc.

-- 

Bruce...        pihlab@hhcs.gov.au
                 ^^
*******************************************************************
* Bruce Pihlamae  --  Database Administration                     *
* Commonwealth Department of Health, Housing & Community Services *
* Canberra, Australia                             (W) 06-289-7056 *
*******************************************************************
* These are my own thoughts and opinions, few that I have.        *
*******************************************************************
Newsgroups: comp.lang.c,comp.lang.pascal,comp.lang.misc
From: ptran@envmsa.eas.asu.edu (Phi-Long Tran)
Subject: Re: Opinions on case sensitivity in programming languages?
News-Software: VAX/VMS VNEWS 1.4-b1  
Reply-To: ptran@asuvax.eas.asu.edu
Organization: Arizona State University, Tempe, AZ
Date: Thu, 10 Sep 1992 22:53:00 GMT

In article <ART.92Sep10132321@world.std.com>, 
art@world.std.com (Al Thompson) writes...

> In article <1992Sep10.034246.14218@oucsace.cs.ohiou.edu>
> tswingle@oucsace.cs.ohiou.edu (Tom Swingle) writes:

>> ...  1.  Do you prefer programming in a language which is case-sensitive
>> or case- insensitive (or does it even make a difference to you), and
>> why?

> Case insensitive all the way.  A cat is the same animal as a cAt.

     Case sensitivity is a useful feature.  One usage is to name #define'd
constants and macros using only uppercase characters.  This capitalization
serves to tell the reader that "this identifier will be replaced; be
careful."  Case sensitivity provides one more mechanism for encoding some
more meaning into an identifier's name.  Some programmers use case to
distinguish between functions and variables, as in Hungarian notation
(e.g., capitalize the first letter in a function name).

>> ...  2.  How significant an issue is case-sensitivity in your preference
>> toward one language over another?

> Not very, but I still think case insensitivity the proper way because of
> its correspondence to natural languages.  Another is an issue of
> correctness.  For example if I have two variable k and K a simple typo
> can turn my program into a pumpkin and the compiler won't say a word.

     I'm not sure that case insensitivity has a correspondence to natural
languages.  It may with "spoken" language, where we stress intonation, etc.
As for the written language, we take great care to distinguish a proper
noun, an acronym, etc. using distinct cases.  As for program correctness,
an undisciplined programmer may choose to change case depending on whether
he/she feels like tapping the shift key, resulting in inconsistencies in
the "form" and therefore, the readability of the code.  Likewise, I wonder
if "k" and "K" are good identifiers at all?

---
Phi-Long Tran
ptran@asuvax.eas.asu.edu
Arizona State University
Xref: sparky comp.lang.c:13589 alt.folklore.computers:13890
From: mzraly@ra.cs.umb.edu (Michael S. Zraly)
Newsgroups: comp.lang.c,alt.folklore.computers
Subject: What is Duff's Device?
Date: 12 Sep 92 09:17:33 GMT
Distribution: na
Organization: University of Massachusetts at Boston
Originator: mzraly@ra.cs.umb.edu

I understand that Duff's Device is a technique used to unroll a
critical loop, along the lines of what one might find in a routine like
memcpy().  Can someone please post or email an example of code using
Duff's Device?

Finally, is Duff's Device named after Bell's Tom Duff?

Thanks,
  Mike

-- 
Mike Zraly		Do not meddle in the affairs of wizards,
mzraly@cs.umb.edu	for you are crunchy and good with ketchup.
From: atmtjkv@vax.oxford.ac.uk
Newsgroups: comp.lang.c
Subject: Re: Help!!! Please Read this message!?!?!?!?!...
Date: 9 Sep 92 07:53:52 GMT
Organization: Oxford University VAX 6620

In article <1992Sep9.043345.15040@nuscc.nus.sg>, eletanjm@nuscc.nus.sg (TAN JIN MENG) writes:
> mcook@melkur.dev.cdx.mot.com (Michael Cook) writes:
> : eletanjm@nuscc.nus.sg (TAN JIN MENG) writes:
> : 
> : >gmr6139@ultb.isc.rit.edu (G.M. Richard ) writes:
> : >: I can't get my compiler to do float-type variables.
> : 
> : ...
> : 
> : >: #define apples  4
> : >: #define oranges 3.6
> : >:  
> : >: main()
> : >: {
> : >:         printf("\nApples = %d\nOranges = %f", apples, oranges);
> : >: }
> : 
> : >Your compiler can't know what orange is... So it assumes that its an
> : >int. That's why the wrong result. Alternatives ...
> : 
> : What?  Don't be silly...  The compiler knows what orange is.
> : 
> : Matt's problem is probably due to Turbo C trying to avoid linking against the
> : floating point library (so as to keep the program smaller).  The compiler saw
> : no "float" or "double" declarations, and so it linked against the non-floating
> : point version of the standard library, and picked-up the non-floating point
> : version of printf, which probably doesn't understand %f.
> 
> 
> If the printf doesn't understand %f, it will print "%f" verbatim and not
> even attempt to interpret it.
> 
> jin meng

Isn't the point rather that oranges is passed as double (vide K&R I p186):
	`Any actual arguments of type float are converted to double before the call....'
so there's a double on the stack.  When printf is called, the format string tells
it how to interpret the stack frame.  It takes apples off as an int, correctly,
because of the %d, but it tries to interpret oranges as a float (%f), when in fact
it has been passed as a double.  So the results will be unpredictable, and will vary from
compiler to compiler. It is possible that some compilers may trap printfs, and look at
the format string at compile time, but it isn't required!

-- 
Tim Kingsmill-Vellacott
Atmospheric, Oceanic and Planetary Physics
University of Oxford, UK.
tjkv@atm.ox.ac.uk  preferred
Newsgroups: comp.lang.c
From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
Subject: Re: Only C gurus allowed?!?!
Organization: Texas Instruments Inc
Date: Wed, 9 Sep 1992 20:41:30 GMT

In <1992Sep9.051107.22938@nuscc.nus.sg> eletanjm@nuscc.nus.sg (TAN JIN MENG) writes:

>I posted something in this group to try to help someone out. 

>I got flaming mail to the effect that I was wrong, that my explanation
>was garbage etc etc and that I shouldn't post in this group (to help
>others) unless I'm very sure of the facts.

>Is there some kind of implicit censorship here? To the effect that only
>C gurus are allowed to help others here?

No censorship that I know of, but if you were wrong, were you really
"helping others"?

>Does it matter whether I was right or wrong? There're plenty of fellas
>here willing to correct me if I'm wrong .... but please don't be
>offensive or [suggest] that I keep quiet.

Yes, it matters quite a bit whether you're right or wrong, if you're
claiming to be giving an answer to someone.  When you ask a question,
does it matter to you whether the answer is right or wrong?
Presumably so, or you would have just made one up instead of asking.
So why would you even question whether it matters whether an answer
you give someone is right or not?  If you don't KNOW the answer, why
answer?  

>Is is just this group or what? I don't get this kind of thing in the
>other groups I suscribe to. 

I would suspect that it happens most in the high-traffic groups.
There is more than enough traffic and more than enough confusion
without having a dozen wrong answers given for every question, and
then having a long series of notes trying to straighten it all out.
Yes, you may feel that you were only one wrong answer, but if you give
a wrong answer, why shouldn't everyone else who doesn't know also post
an 'answer'.  How is the poor guy asking the question supposed to
figure out what's right, without there being a whole flurry of
corrections from people who DO know the answer?

If you don't know the answer, it's best to sit back and let someone
else handle the question.


-- 
"Insisting on perfect safety is for people who don't have the balls to live
 in the real world."   -- Mary Shafer, NASA Ames Dryden
------------------------------------------------------------------------------
Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
Newsgroups: comp.lang.c
From: cee1@ra.msstate.edu (Charles Evans)
Subject: Re: Dropping a n from a fprintf()
Organization: Mississippi State University
Date: Fri, 11 Sep 1992 18:49:20 GMT

fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:

>cee1@ra.msstate.edu (Charles Evans) writes:

>>	while ((fgets(fp1,20,item)) != 0)

>This should be fgets(time,20,fp1).
>For some unknown reason the FILE* argument to fgets is the last argument,
>instead of the first.

I apologize for not just including ACTUAL code .. I typed it in quickly
by hand , and inadvertantly swapping the order of arguments... sure wish
they were in the same place for everyting...

BUT THANKS EVERYONE WHO HELPED.. I HAVE A PLETHORA OF GREAT AND HELPFUL
ANSWERS!!!!.. now to stick them in _my_ faq.. cause this time next year, I
wont remmeber
:)

>-- 
>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!
-- 
+--------------------+-----------------------+------------------------+
|  Charles E. Evans  |  cee1@ra.msstate.edu  |  All things are green  |
|    iDLE CHATTEr    |  cee1@MSSTATE.BITNET  |  unless they are not.  |
+--------------------+-----------------------+------------------------+
Newsgroups: comp.lang.c
From: ifkm@hippo.ru.ac.za (Andrew Murdoch)
Subject: Address of static variables??
Summary: Is address of statics constant?
Keywords: static variables
Organization: Rhodes University, Grahamstown, South Africa
Date: Fri, 11 Sep 1992 11:59:12 GMT


Consider this scenario:

char *a_pointer;

void some_function()
{
   static char some_string[] = "Anything";

   // Do whatever here
   a_pointer = some_string;
}

void another_function()
{
   ... some stuff
   do something with a_pointer
}

Is the static variable some_string always guaranteed to have
the same address?  That is, will a_pointer always be a valid
pointer?  Of course some_function would have to be called first.
-- 
     |\/|     v |     ANDREW MURDOCH   -   Institute for Water Research
 /_\ |  | \___@ |  Rhodes University, P.O. Box 94, Grahamstown, 6140, R.S.A.
/   \     /   \ | Internet: ifkm@hippo.ru.ac.za     Phone: [xx27] [0]461 24014
Newsgroups: comp.lang.c
From: ksc@cbnewsk.cb.att.com (kenneth.s.cobler)
Subject: Re: argv in main
Organization: AT&T
Distribution: na
Date: Wed, 16 Sep 1992 00:17:33 GMT
Keywords: argv, main(), NULL

In article <Sep.10.23.54.35.1992.4694@ruhets.rutgers.edu> ghe@ruhets.rutgers.edu (Guangliang He) writes:
>It may be a FAQ, but I could not find it in the FAQ list.
>
>According to the "C: A Reference Manual" (2nd Edition, by Harbison &
>Steele), the argument argv[argc] of main(argc, argv) may be a null
>pointer, but is not so in allimplementations. How safe is it to assume
>argv[argc] == NULL ? Should I be cautious about this?
>

Yes, this is something to be cautious about.  I would suggest decrementing
argc and then accessing argv variables or using a loop to accessing the
argv variables.

Example:

main(argc, argv)
int argc;
char *argv[];
{
	argc--;
	do {
		/* use argv[argc] */
	} while (argc--);

	/* OR */

	for (i = 0; i < argc; i++) {
		/* user argv[i] */
	} /*end for*/

} /*end main*/


Kenneth Cobler		ksc@cbnewsk.att.com or ken@ihlpm.att.com
AT&T Bell Laboratories	attmail!cbnewsk!ksc or attmail!ihlpm!ken
2000 N. Naperville Rd.
Naperville, IL  60566
From: g-yao@cs.yorku.ca (Ling Yao)
Newsgroups: comp.lang.c
Subject: extern struct
Date: 9 Sep 92 03:04:36 GMT
Article-I.D.: yetti.1428
Distribution: world
Organization: York University, Dept. of Computer Science

Hi, dear friends:

	As a ``C'' novice, I would  like to ask some advice about how to 
	use extern struct.


what I did:

----------------file 1------------------------------
struct point{
	float x;
	float y;
	float z;
	};

	static struct point p[100][100];

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

------------------file 2----------------------------
extern struct point p[100][100];
---------------------------------------------------


I would apprecite it very much if anybody can help me.
Please answer this to g-yao@cs.yorku.ca if it's convenient to you.


Thanks in advance.
-- 

+-------------------------------------------------------------+
| Ling YAO                        "I die when it's time for   |
| Department of Computer Science   me to die. So let me live  |
From: beers@acsu.buffalo.edu (Andrew Beers)
Newsgroups: comp.lang.c
Subject: Database libs?
Date: 5 Sep 92 16:15:21 GMT
Organization: State University of New York at Buffalo/Comp Sci


Are there any C/C++ libraries for manipulating databases?  I'd like to be able
to create databases with arbitrary records, and at least be able to search
through then, possibly in an indexed fashion.

I don't normally read this group, so email replies would be most appreciated.
If I get a number of "me too" responses, I'll summarize through the net.

Thanks in advance.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
andrew c. beers, n2luh             beers@cs.buffalo.edu  
suny buffalo, computer science     {rutgers,uunet}!cs.buffalo.edu!beers
Xref: sparky comp.lang.c:13642 comp.lang.c++:13617 comp.os.msdos.apps:4741 comp.os.msdos.programmer:9350
From: grant@pentagon-gw.army.mil (Pete Grant)
Newsgroups: comp.lang.c,comp.lang.c++,comp.os.msdos.apps,comp.os.msdos.programmer
Subject: Re: Should I buy BC++ 3.1??
Date: 12 Sep 92 20:37:23 GMT
Organization: U.S. Army Artificial Intelligence Center, The Pentagon

In article <1992Sep3.174207.21362@ra.msstate.edu> cee1@ra.msstate.edu (Charles Evans) writes:
>Well, info from customer-support@borland.com says the educational price
>for BC 3.1 is $139.99. However, I was cruisin' thru the university bookstore/
>computer place and they have it for $99.00. Ok.
>
Probably a case of Apples vs. Oranges.  If either of those packages includes
the Application Frameworks, buy it now!  I paid $200 for mine as an upgrade.

>[stuff deleted]... I know that v. 3.1
>is compatible with WIn 3.1 (I'd lvoe to learn how to program in Windows) and
>
Pardon if my bias shows -- but I've been a long time user of Borland products
and have dabbled with several other PC IDE products to include IBM OS/2 
Workframe 2, MS PWB, etc.  None of them can hold a candle to Borland!!!!
(IBM actually comes close :-)).

Development of Windows programs with BC++ 3.1 is a breeze.  The OWL (Object
Windows Library) is a great help in learning Windows as well as increasing
productivity..

The only negative thing I can say about BC++ 3.1 is that it's a 16-bit
compiler.  A 32-bit compiler is supposedly to be released later this yr.
>
>(I think) DOS 7.0 will be a COMPLETE rewrite redo everything. Should I wait?
>
My suggestion:  Forget DOS.  GUI-based operating systems are the future
in this business.  As soon as Windows NT and OS/2 are established, only
a few die-hards will still be running DOS.  Let the people with old
8088's have it.

If you are planning on a career in software engineering (programming),
you MUST learn to program Windows or another GUI.  Five years from now
*NOBODY* is going to hire people to develop character-based user interface
applications.

>any pointers or pointers to pointers to int would be helpful.
>
Ok, Ok, I'm getting off my soap box...

Pete.
Newsgroups: comp.lang.c
From: cxd653@huxley.anu.edu.au (Chunping Ding)
Subject: Increase argument accuracy
Originator: cxd653@huxley
Organization: Australian National University
Date: Fri, 11 Sep 92 15:03:10 GMT

Could any one tell me how to increase the accuracy of the argument, if I
feel double is still not enough?

For example, I have following code:

#include <stdio.h>
main(){

 float tmp1,tmp2;
 double x;
 int i;

 x=1365603121.11;
 tmp1=0.1;
 printf("x= %f tmp1= %f x*tmp1= %f\n",x,tmp1,x*tmp1);

}

I expect to get the result:

 x= 1365603121.11 tmp1= 0.1 x*tmp1= 136560312.111.

But, instead, I obtain the folowwing result:

 x= 1365603121.110000 tmp1= 0.100000 x*tmp1= 136560314.145907

Help me, please!

Please email me your reply. Thank you!

Ding Chunping

________________________________________________________________________

(Mr.) Ding Chunping             Telephone 61 6 249 4205 or 61 6 249 2066
Geology Department              Fax       61 6 249 5544                 
Australian National University  Email:    cxd653@huxley.anu.edu.au
GPO Box 4, Canberra, ACT 2601             ding@basins.anu.edu.au
Australia                                 ding@grafix.anu.edu.au
________________________________________________________________________
Newsgroups: comp.lang.c
From: mjn@pseudo.uucp (Murray Nesbitt)
Subject: Re: main()
Organization: Private system in Toronto, ON
Date: Thu, 10 Sep 1992 08:08:55 GMT
	<1992Sep8.125611.28009@microware.com>


adam@microware.com (Adam Goldberg) writes:

>doug@tisdec.tis.tandy.com writes:
>
>>Actually main() is defined as
>
>>  int main(int argc, char **argv, char *envp);
>
>Actually, main() is defined as
>   int main(int argc, char **argv, char **envp);
>
>although it probably should be unsigned int main(...) since what
>does a negative return code return to the OS?

A strictly conforming program, in a hosted environment, must define
``main'' as one of the following:

        int main( void ) { [...] }
        int main( int argc, char **argv ) { [...] }
        int main( int argc, char *argv[] ) { [...] }

The names ``argc'' and ``argv'' are arbitrary.

-- 
Murray
Newsgroups: comp.lang.c
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Command Line Arguments
Organization: Computer Science, University of Melbourne, Australia
Date: Fri, 11 Sep 1992 07:02:13 GMT

adam@microware.com (Adam Goldberg) writes:

[...]
>void main(int argc, char **argv);

As noted in many recent articles on this newsgroup, this should be
	int main(int argc, char **argv);
	^^^
because main() must return an int.

-- 
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
From: tony@nexus.yorku.ca (Anthony Wallis)
Subject: Re: Help! <math.h> strangeness
Organization: York University
Distribution: usa
Date: Thu, 10 Sep 1992 01:27:22 GMT

Steve Sigmond (sigmond@leland.Stanford.EDU) wonders
> .. why the following program won't work:
> #include <math.h>
> main() { printf("%f\n",sqrt(3.0)); }
>.. "cc test.c" .. error message "ld: undefined symbol: _sqrt".

Yeah, we all discover this sooner or later.  You probly hafta
                    "cc test.c -lm".
It's nothing to do with the <math.h> include file (which is food only
for the preprocessor anyway), but with where the loader looks.  Why some
places are implicit and others need explication is nothing to do with
the programming language C, but is an aspect of a Unix environment.
And, in my humble opinion, this is bloody awfully badly documented !
(OK, I don't have the programmatically correct tomes.)

--
tony@nexus.yorku.ca = Tony Wallis, York University, Toronto, Canada
From: dave@cs.arizona.edu (Dave Schaumann)
Newsgroups: comp.lang.c
Subject: Re: problem with "external pointer"
Date: 7 Sep 92 17:57:40 GMT
Reply-To: dave@cs.arizona.edu (Dave Schaumann)
Organization: University of Arizona

In article <xu.715880256@prim.rose.utoronto.ca>, xu@prim (Jiefeng Xu) writes:
>Hi,netters! I have a problem which for you experts may be quite easy. Can I
>define a pointer and use it as an external variable?

Sure.  I do this all the time.

>If I use the following
>
>extern int *ps;
>
>my compiler (gcc) will ignore it and consider the ps as undefined.

What you have to understand is that "extern int *ps;" is a /definition/ of
"ps".  You still need to have a declaration of "ps" somewhere in your source
code.  If you don't, the linker will complain (and rightly so).

-- 
--- jumbo shrimp --- pretty ugly --- awfully nice --- constant change ---
From: ageorge@ra.nrl.navy.mil
Newsgroups: comp.lang.c
Subject: Re: Most difficult part of learning C?
Date: 4 Sep 92 23:42:51 GMT
Reply-To: ageorge
Organization: Naval Research Laboratory, Washington DC
News-Software: VAX/VMS VNEWS 1.3-4

In article <9208251159.AA04122@ult4>, goldstei@cgi.com ("Morris Goldstein") writes...
>I am conducting research for a little project concerning difficulties in
>learning C and how to improve the teaching of C so as to circumvent these
>problems.
> 
>When learning C, what things did you find the most confussing/difficult to
>understand?
> 
>        -Morris
> 
>(goldstein@cgi.com)

	Morris,

	I'm glad you asked.
	For me the thing I found most confusing or difficult when learning C
centered on parameter passing. It seems as if can do this in a number of ways,
and, in the case of passing character pointers, sorting these ways out was
not trivial.

	Your intent is to improve the reaching of C. I suggest placing
an emphasis on parameter passing and encouraging your students to adopt
a convention of parameter passing. Allow them the opportunity to spend time
writing code instead of fussing about parameter passing.

	Thank you for asking,

	Arthur George, NRL
	ageorge@BDCI143.nrl.navy.mil
From: barmar@think.com (Barry Margolin)
Newsgroups: comp.lang.c
Subject: Re: 1992 International Obfuscated C Code Contest winners
Date: 12 Sep 1992 02:22:38 GMT
Organization: Thinking Machines Corporation, Cambridge MA, USA
NNTP-Posting-Host: telecaster.think.com

In article <268@talgras.UUCP> david@talgras.UUCP (David Hoopes) writes:
>In article <1992Sep10.135002.25527@wraxall.inmos.co.uk> nathan@elberton (Nathan Sidwell) writes:
>>Landon C. Noll (chongo@hoptoad.uucp) wrote:
>>As chongo stated, my entry can't be posted from the USA.
>Why couldn't your program be posted from the U.S?

I haven't examined it, but I'll bet if you figure out what it does, you'll
realize that posting it from the US and allowing it to propogate outside
the US would be a violation of export control laws regarding munitions.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

barmar@think.com          {uunet,harvard}!think!barmar