HDTenEightyP/NetNews huggingface dataset:
From: dfuller@portal.hq.videocart.com (Dave Fuller)
Subject: Re: Search function algorithms
Organization: VideOcart Inc.
X-Newsreader: Tin 1.1 PL3
Distribution: comp
Date: Tue, 17 Nov 1992 06:49:11 GMT

corvett@cs.bu.edu (Sungyeup Kim) writes:
: 
: Hi, 
: Could somebody give me a very nice and easy search algorithm. 
: What I want to do is after I get a string(I don't know the length) 
: I want to check whether it's in the array or not.
: 
: Thanks in advance !!!

Easy. bsearch() c library function will do it. If your array isn't
sorted before the call, use qsort(). Both are documented in reference
books, work easily, and quickly.

Dave Fuller
dfuller@portal.hq.videocart.com

Newsgroups: comp.lang.c,comp.software-eng
From: johnson@cs.uiuc.edu (Ralph Johnson)
Subject: Re: Will we keep ignoring this productivity issue?
Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
Date: Wed, 18 Nov 1992 22:44:18 GMT

shanks@saifr00.cfsat.honeywell.com (Mark Shanks) writes:

>>>I maintain that superior programming ability is inherent; it can be

>Please note I said "SUPERIOR" ability.

and then he goes on to equate superior ability with being a genius.

The studies that claim that there is several orders of magnitude
differences between the effectiveness of programmers did not consider
geniuses.  They were looking at programming groups in single
companies.  The difference between the top 10% and the bottom 10%
was very large.  Probably none of these people were geniuses.

>>you can teach leadership,

>That's wrong.  I went to the AF Academy, where they TRY to teach
>leadership, but I assure you, some people can LEAD, and the rest
>are fated to be managers at best.

I know families where every child is a "born leader".  However,
it is probably not genetic.  It is probably taught.  There are
some things that you have to teach at an early age, and it is too
late if you start when you are 17.  That is certainly true of
foreign languages, music, ballet and gymnastics, and probably is
true of leadership, too.

>> Practice, hard work, and desire are the main attributes
>>necessary to developing skill.

I still think that one of the main things that makes a superior
programmer is that he or she likes it so much that practice comes
naturally.  I would be very happy programming 10 or 12 hours a
day.  Once I was able to do that, and I did for many years.  That
is as an important a cause of my programming skills as my logical
thinking.

Native ability is a factor in everything that we do.  But in the
nature vs. nurture debate, I think that nurture probably is the
most important in the end.  In the case of programmers, most of
the people prevented by nature from being good programmers probably
aren't interested anyway.

Ralph Johnson -- University of Illinois at Urbana-Champaign
From: marby@laura.harvard.edu (Craig Marby)
Newsgroups: comp.lang.c
Subject: Re: How to malloc an array of pointers?
Date: 19 Nov 92 20:21:48 GMT
Organization: Chemistry Dept., Harvard University
In-reply-to: dfuller@portal.hq.videocart.com's message of 19 Nov 92 14:06:10 GMT

sbtaves@icaen.uiowa.edu (Steven Bradley Taves) writes:
: Hi all,
: 
:     I'd appreciate it if someone could tell me how I can allocate memory
: for an array of pointers and for the strings they will be pointing to.
: 
: I have  
:        char *Var[];
: 
: Normally for
:        char *Var;
: you do
:        Var=(char *)malloc(10*sizeof(char));
: for a string of 10 characters.
: 
: I want to allocate memory for 10 strings of ten characters.  Also, how
: do I allocate memory for the pointers themselves?
: 

> On 19 Nov 14:06:10 GMT, dfuller@portal.hq.videocart.com (Dave Fuller) said:
Dave> try this:

Dave> instead of char *Var[] -> char *Var[10]  (since you know you have 10)
Dave> this will also allocate the memory for you automatically (for pointers)

Dave> then without any error checking of course

Dave> for (i = 0; i < 10; i++)
Dave>    Var[i] = (char *) malloc(10 * sizeof(char));

Below is sample code that at run-time can handle a variable number
of strings for those who are interested.

#define STRING_COUNT  10
#define STRING_LENGTH 10
main()
{
   int i;
   char *(*Var)[];

   Var = (char *(*)[]) malloc(STRING_COUNT);

   for (i = 0; i < STRING_COUNT; i++)
      (*Var)[i] = (char *) malloc(STRING_LENGTH);
}
--

    __o         
  _ \<,_       Craig A. Marby    marby@layla.harvard.edu
 (_)/ (_)      
~~~~~~~~~~
Newsgroups: comp.lang.c
From: darcy@druid.uucp (D'Arcy J.M. Cain)
Subject: Re: Finding length of file?
Date: Mon, 16 Nov 1992 22:11:11 GMT
Organization: D'Arcy Cain Consulting

fjeske@amiganet.chi.il.us (Felix Jeske) writes:
>Yes there is.  Just fseek() to the end of the file via:
>                           fseek(fp,0,SEEK_END);
>and then ftell(fp) to get the size in bytes.

Wrong.  This might get the size of the file on some systems depending on
how the file is opened and what you mean by "file size."  See the FAQ
question 16.7.

-- 
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: rene@hamel.uucp (Rene Mueller)
Subject: Re: question about duplicate declarations
Organization: Free University of Berlin, Germany
Date: Thu, 19 Nov 1992 16:11:53 GMT

In article <720329596@sheol.UUCP>, throopw@sheol.UUCP (Wayne Throop) writes:
|> I didn't see anybody else mention it specifically, but it's relevant to
|> some of the earlier postings; note that:
|> 
|>          float a(float);
|>          void f(void) {
|>                  float a();       /* gak! */
|>                  ...
|>          }
|> or
|>          short a(short);
|>          void f(void) {
|>                  short a();       /* gak! */
|>                  ...
|>          }
|> 
|> is *also* a malicious redeclaration, not a benign one.  Arguably, the
|> compiler could deal with the inner by "enhancing" it to match the outer
|> (though this is a Bad Idea in my opinion), but there would be a good
|> deal more trouble with, eg:
|> 
|>          float a();
|>          void f1(void) {
|>                  a(1.0);
|>          }
|>          void f2(void) {
|>                  float a(float);       /* gak! */
|>                  a(1.0);
|>          }

In a function there couldn't be a fuctiondefinition..
So code like
typ f1(paramlist)
{
typ f2(paramlist);
	.
	.
	.
}
Shouldn't be in ANY programm...
and things like
typ f();
means that f is a function with NO parameter returning a value from type typ
(perhaps nothing if typ==void), so typ f(paramlist) is a redeclaration with WRONG
type
That means:

float a();

void f1(void)
{
	a(1.0);
}

void f2(void)
{
float a();
	a(1.0);
}

won't produce an error (perhaps a warning: "parameter to a() ignored").

	Rene
From: scott.golby@f54.n54.z3.fido.zeta.org.au (Scott Golby)
Newsgroups: comp.lang.c
Subject: GRAPHICS LIBRARY'S
Date: 7 Nov 92 14:00:02 GMT
Organization: Fidonet. Gate admin is fido@socs.uts.edu.au


        Hi Everyone,  (especially those with experience using the various
Graphics Libraries that are around for C)

        I was wondering if some one coule give me a run down on the Graphics
Library's available for the Borland C++ enveronment?

        What functions are provided by the various ones?  
        How large does it make the execuatable?  (The only real library
experience I have had was with CLIPPER, and clipper.lib when linked in would
blow out a small menu program from a 2K source to a 200K EXE!)  
        What ones are the best?

        Thanks for your time!

      'C' ya,                                              Scott Golby.
  

--- TMail v1.31
 * Origin: Prophet BBS - Western Sydney, Australia (3:54/54)
Newsgroups: comp.lang.c
From: alpha@waggen.twuug.com (Joe Wright)
Subject: Re: write an int?
Organization: ALPHA, Box 68621, Va. Beach, VA 23455
X-Newsreader: TIN [version 1.1 PL6]
Date: Sun, 22 Nov 1992 00:03:30 GMT

O. C. (map@ratt.rutgers.edu) wrote:
: 
: I want to write an integer to a text file using the Unix system call
: write,
: 
: write(file descriptor,buffer,size);
: 
: but I can only seem to get it to work for strings and characters.
: 
: What am I doing wrong?

Why write().  Why not C's fwrite()?  In any case, an integer is not
text.  Use fprintf() to convert an int to text on the output file.

-- 
Joe Wright  alpha@waggen.twuug.com  
"If we could only see the source code.."  (Dave Olson)
From: fahad@cs.pitt.edu (Fahad A Hoymany)
Newsgroups: comp.lang.c
Subject: 2-D Arrays Problem Solved
Date: 19 Nov 92 02:06:46 GMT
Article-I.D.: pitt.17514
Organization: Univ. of Pittsburgh Computer Science

Thanks to all of the people who responded to my question on passing 2-D
arrays of varying sizes to a function.  In particular, the answer below
which sums up all the other ones was provided by Shawn Willden.

/******** Some of those who responded *********************
From: hwu@scf.usc.edu (Hung-Yao Wu)
From: Pete Holsberg <pjh@mccc.edu>
From: swillden@icarus.weber.edu (Shawn Willden)
From: joe@monroe.pilot.dmg.ml.com (Milamber)
From: jamshid@emx.cc.utexas.edu (Jamshid Afshar)
From: William Kaufman <wkaufman@us.oracle.com>
/*********************************************************/
int main()
{
 int a[2][2], b[3][3];
 a[1][1] = 1234;
 b[1][1] = 33;
 printf("Before, a[1][1] = %d\n", a[1][1]);
 printf("Before, b[1][1] = %d\n", b[1][1]);

 proc(&a[0][0], 2, 2);
 proc(&b[0][0], 3, 3);
 printf("After, a[1][1] = %d \n", a[1][1]);
 printf("After, b[1][1] = %d \n", b[1][1]);
}
/*****************************************************/
int proc(int *a, int r, int c)
{
 int i, j;

 for (i=0; i<r; i++)
   for (j=0; j<c; j++) 
      a[c*i+j] = 88;
}

..Fahad@speedy.cs.pitt.edu
Newsgroups: comp.lang.c
From: d0np@elara.sun.csd.unb.ca (Godzilla)
Subject: Re: fwrite & fread
Organization: University of New Brunswick
Date: Thu, 19 Nov 1992 13:15:29 GMT

#In article <92324.000622U17868@uicvm.uic.edu>, <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.
|> I have also included a part of my header file which contains the structure.
|> Thanks in advance,
|> Sikander Waheed    email: u17868@uicvm.cc.uic.edu
|> 
|> #include <stdio.h>
|> 
|> #include <stdlib.h>
|> typedef struct activity{
|> 	int  id;
|> 	int  mm;
|> 	int  dd;
|> 	int  yy;
|> 	char day[10];
|> 	int  hour;
|> 	int  min;
|> 	int  end_hour;
|> 	int  end_min;
|> 	char location[25];
|>         char with_who[20];
|> 	char phone[11];
|> 	char subj[30];
|> 	char note[300];
|>         int  flag;
|> };
|> 
|> void add()
|> {
|> int a,mm,dd,yy,hour,min,st_hour, end_min = 0 , t2_hour, t2_min, i = 0, ok;
|> char ch;
|> FILE *file_pointer;
|> struct activity temp;
|>  ok = busy(mm, dd, yy, hour, t2_hour);
|>  if(ok == 1)
|>    {
|>
          .
          . (stuff deleted)
          . 

|> 	 a = fwrite(&temp, sizeof(temp), 1, file_pointer);

You are writing out sizeof(temp) number of bytes, and since temp is a 
struct activity, which has 300+30+11+20+25+10+9*2 = 414 bytes assuming
int is 2 bytes.  Try printing sizeof(temp) to see what you get.

|> 	 a = ferror(file_pointer);
|> 	 a = fclose(file_pointer);
|> 	 a = ferror(file_pointer);
|> 	 setvbuf(file_pointer, NULL , 194, _IOFBF);
|> 	 ch = getchar();
|>      } /* end if */
|>     return;
|> }
|> 
|> 


                                    Hope this helps 
                                       Mike


d0np@jupiter.sun.csd.unb.ca 
d0np@unb.ca
Newsgroups: comp.lang.c,comp.lang.c++,alt.tasteless.jokes,rec.humor
From: hildum@ntmtv.UUCP (Eric Hildum)
Subject: Re: *** IMPORTANT DISCOVERY ***
Organization: Northern Telecom Inc, Mountain View, CA
Date: Mon, 16 Nov 1992 23:49:18 GMT

Hmmm, I guess suomebody forgot to log out....
Xref: sparky comp.lang.c:16801 comp.software-eng:4402
From: kambic@iccgcc.decnet.ab.com (Bonus, Iniquus, Celer - Delegitus Duo)
Newsgroups: comp.lang.c,comp.software-eng
Subject: Re: Will we keep ignoring this productivity issue?
Date: 19 Nov 92 11:21:16 EST

In article <BxxoHu.Lpz@cs.uiuc.edu>, johnson@cs.uiuc.edu (Ralph Johnson) writes:
[...]
> 
> I know families where every child is a "born leader".  However,
> it is probably not genetic.  It is probably taught.  
[...]
> Native ability is a factor in everything that we do.  But in the
> nature vs. nurture debate, I think that nurture probably is the
> most important in the end.  In the case of programmers, most of
> the people prevented by nature from being good programmers probably
> aren't interested anyway.

I don't think this belongs here. We are in the world of wild conjecture and the
nature vs. nuture issue could go on forever.  We need to speak of data here.  I
will offer one anecdotal (hah!) in support of Mark ? Mike?.  In my experience
(+17 yrs sw) leaders are born not taught.

George Kambic
sd

Newsgroups: comp.lang.c
From: root@ufps9.unifr.ch (Laurent Schmutz)
Subject: Re: Multiple Parameter Passing (unspecified number)
Organization: University of Fribourg - CH
Date: Tue, 17 Nov 1992 13:03:52 GMT

In article <BxtrFG.Fq4@portal.hq.videocart.com>, dfuller@portal.hq.videocart.com (Dave Fuller) writes:
|> GNR100@psuvm.psu.edu writes:
|> : 
|> :    Hi.
|> : 
|> :    I'm looking to write a function that accepts any number of paramerter.
|> : There will be at least two, an int and a char[]. The rest will all be char[]'s.
|> : I need to know how this is done.  The meathod would be similar to that of
|> : printf(), so if anybody know how that works, please let me know.
|> :                  Thanks,
|> :                      Gordon Rogers
|> :                      gnr100@psuvm.psu.edu
|> 
|> 
|> Gordon,
|>     Sort of depends. UNIX versions will use definitions from varargs.h and 
|> non-UNIX platforms use stdarg.h (I believe these are the correct header files).
|> 
|> UNIX versions use va_dcl, va_start, va_end, va_arg, va_list,va_start, va_end, va_arg, va_list,va_start, va_end, va_arg, va_list, and va_alist
|> non-UNIX versions use va_end, va_arg, va_list
|>                       and va_start (with 1 extra parm)
|> (not all of these are macros. va_alist, va_dcl, and va_list are variables)
|> 
|> I haven't used varargs in a while so this may not be complete.
|> 
|> Sorry this is not a full-blown answer, but if it doesn't get you headed
|> in the right direction, write me. As i said, i will respond with full
|> functional usage of the variable argument scheme.
|> 
|> 
|> Dave Fuller
|> dfuller@portal.hq.videocart.com
|> 

Perhaps something more Dave,

In the Kernighan & Ritchie's book "The ANSI-C programming language - second edition"
(1988) the use is restricted to

		va_start, va_end, va_arg, va_list

		coming from <stdarg.h>

We can so suppose that a normallized ANSI-C compiler will accept these. Tell me if not.
Best regards.

							Laurent Schmutz
							schmutz@CFrUni52.bitnet
Newsgroups: comp.lang.c
From: cflatter@nrao.edu (Chris Flatters)
Subject: Re: Reasons for using C vs. Fortran or vic
Reply-To: cflatter@nrao.edu
Organization: NRAO
Date: Sun, 15 Nov 92 23:13:11 GMT

In article 20678@thunder.mcrcim.mcgill.edu, mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
>In article <1992Nov13.162451.13049@zia.aoc.nrao.edu>, cflatter@nrao.edu (Chris Flatters) writes:
>
>> Storing arrays by column or by row doesn't make any difference
>> whatsoever to the speed of matrix operations: it is merely a notation
>> change.
>
>This is true only in the abstract.  I have experienced (not just heard
>about) multiple orders of magnitude speed differences, because going
>through arrays "the wrong way" had catastrohpically bad VM behavior:
>essentially, every access involved a page fault.  Doing it "the right
>way" stepped through VM in a nice sequential way, with minimal paging.

This is true.  The cost of moving data around is often higher than the cost
of computation.  Generally speaking you want to keep accesses that are close
together in time close together in memory: VM isn't the only constraint ---
you make the most out of modern RISC machines by working in cache as much as
possible.

Storing arrays by column or row doesn't actually make much difference here
(although not knowing which convention you are using can hurt you).  For
large linear algebra problems blocked algorithms (as used in LAPACK) are
the methods of choice (see, for example "Solving Linear Systems on
Vector and Shared Memory Computers" by Jack Dongarra and several others
(SIAM, 1991)).


>					der Mouse
					^^^

Like Matthias Blume, I've always been curious about this.

	Chris Flatters
	cflatter@nrao.edu


Newsgroups: comp.lang.c
From: moeller@gwdgv1.gwdg.de
Subject: order of 'external' declarations
Reply-To: moeller@gwdgv1.gwdg.de
Organization: GWDG Goettingen, F.R.Germany
Date: Fri, 20 Nov 1992 20:48:23 GMT

I've just come across a supposedly ANSI-compatible C compiler that chokes on

	func()
	{
		extern char *var;
		...
	}

	char *var = "some text";

With functions, this kind of "forward" declaration is quite normal,
so I think it should also be ok with data (for which you have 
to explicitly use 'extern'). Any opinions?

Wolfgang J. Moeller, GWDG, D-3400 Goettingen, F.R.Germany | Disclaimer ...
PSI%(0262)45050352008::MOELLER      Phone: +49 551 201516 | No claim intended!
Internet: moeller@gwdgv1.dnet.gwdg.de   | This space intentionally left blank.
Xref: sparky comp.lang.c:16663 comp.unix.questions:13512
From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
Newsgroups: comp.lang.c,comp.unix.questions
Subject: Re: Wait for child
Date: 17 Nov 92 12:54:28 GMT
Followup-To: comp.unix.questions
Organization: McGill Research Centre for Intelligent Machines

In article <1992Nov16.122725.15971@alf.uib.no>, singg@alf.uib.no (Kurt George Gjerde) writes:

> On Unix, how can I have a process wait for it's child process to do
> something (not terminate).

This is a UNIX question, not a C question.  Consequently, I'm
cross-posting to comp.unix.questions and directing followups there.

There are multiple ways.  You can have the child send some signal to
the parent.  You can create a pipe (or other stream connection) and
have the child write and the parent read.  You can use semaphores, if
your system provides them.  There are probably other ways that don't
come to mind at the moment.

Which one is best?  That depends on many factors, such as the required
response time, how much information needs to be passed (besides the
bare fact of the wakeup), how widely portable the code needs to be,
what if anything the parent is doing while waiting....

					der Mouse

			    mouse@larry.mcrcim.mcgill.edu
Newsgroups: comp.lang.c
From: aaronk@county.lmt.mn.org (Aaron S. Kurland)
Subject: Re: The Correct Way To Write C if-Statements
Organization: LaserMaster R&D
Date: Wed, 18 Nov 1992 02:06:12 GMT

In article <604@ulogic.UUCP> hartman@ulogic.UUCP (Richard M. Hartman) writes:

	[ nasty spaces on both sides of parens examples deleted]

>I finally convinced 'em of the futility of this one though.  But they
>still insist on:

>        if (x == y)
>                flag = TRUE;
>        else
>                flag = FALSE;

>instead of believing that:

>        flag = (x == y);

>actually works.   What do you have to say about that one?

When I see this I just shake my head and laugh!

What do you think of this style?

if (cond)
{
   statement1;
}
else
{
   statement2;
}

I always use the curlys even if there is only one statement in the block so 
if I ever need to add another (or a debug statement) I can do it easily.  I 
also like having the curly braces line up with the conditional statment.

Aaron

-----------------------------------------------------------------------------
"Treasures to satiate desires both subtle and gross."
                                        - Spalding Gray

  My company has not yet accepted my application for Corporate Spokesmodel.

        Mail: aaronk@county.lmt.mn.org       Flames: alt.dev.nul
-----------------------------------------------------------------------------
Newsgroups: comp.lang.c,comp.lang.c++,alt.tasteless.jokes,rec.humor
From: kurgan@spock.uucp (Andrew Twyman)
Subject: Re: *** IMPORTANT DISCOVERY ***
Organization: Choate Rosemary Hall
Date: Thu, 19 Nov 1992 00:52:09 GMT

In article <1992Nov18.235959.3071@spock.UUCP> aorpha@spock.uucp (Andreas Orphanides) writes:
>In article <1992Nov16.221156.18458@spock.UUCP> kurgan@spock.uucp (Andrew Twyman) writes:
>>In article <1992Nov13.210911.3086@msuinfo.cl.msu.edu> knaggs@cps.msu.edu (Scott A Knaggs) writes:
>>>"Will you do anything for me?", I asked. "Yes", was your answer. I asked you
>>>to lay down. You did. I squated right above your head and again, your tongue
>>>started to do it's job. You heard me make a strange noise: "NNNNNNGGGGG".
>>>You thought it was my extasy, but you soon found out it was something else.
>>>You felt something drop on your nose, something which slid slowly into your
>>>mouth. Your curious tongue tried to find out what it was. Congratulations,
>>>you just tasted a piece of shit! You really liked it. It turned you on even
>>>more and I started to grap some off your head and massaged your dick
>>>with it. Your dick looked great, nice and brown with little lightbrown thick
>>>pieces on it.  I started to give you a blow job. I really enjoyed the taste
>>>of cock combined with shit. Especially after you came... I turned around with
>>>my mouth full and kissed you. I emptied my mouth in yours. You passionately
>>>returned my kisses. After that we layed in each others arms for minutes.
>>>You had a big smile on your face.
>>
>>Not only is this too sick to be on rec.humor (which isn't necessarily bad),
>>but it's nauseating and DUMB!  Keep it out of my face.  You're even more of a
>>pervert than I am, and that's a sick thought.
>>-- 
>>-------------------------------------------------------------------------------
>>|  -"I have something to say.  It's better to burn out, than to fade away!"-  |
>>|                          -* THERE CAN BE ONLY ONE *-                        |
>>kurgan@choate.edu--------------------------------------------------------------
>
>Well, my aarch-nemisis, i see that in one field we agree.
>
>PERVERTS SHOULD BE KEPT OFF THE NET. man, that paragraph is grosser than kurgan's (in real life) face!

Pitiful Ramirez.  I had his head and took his woman before the day was out!
-- 
-------------------------------------------------------------------------------
|  -"I have something to say.  It's better to burn out, than to fade away!"-  |
|                          -* THERE CAN BE ONLY ONE *-                        |
kurgan@choate.edu--------------------------------------------------------------