HDTenEightyP/NetNews huggingface dataset:
From: fischer@iesd.auc.dk (Lars Peter Fischer)
Newsgroups: comp.lang.c
Subject: Re: Parameter passing & data abstraction
Date: 9 Jan 93 02:33:07 GMT
	<24524@alice.att.com> <1993Jan1.002606.13612@organpipe.uug.arizona.edu>
Organization: Mathematics and Computer Science, Aalborg University


>>>>> "Dave" == Dave Schaumann (dave@cs.arizona.edu)

Dave> I spoke to the person responsible for maintaining gcc and g++ at
Dave> our site, and he said

Dave> g++ 1.40 needs to use the GNU loader, to resolve the munged
Dave> function names and do creator/destructor calls.  GNU ld doesn't
Dave> grok dynamic libraries, so you end up binding a large portion of
Dave> libc (and, in your case, libg++) into the binary.

Just for the record, I get a file size of 16k with G++ 2 (GCC 2,
really), with 8k text and 8k data. Version 2 will do dynamic linking
OK -- time for an upgrade.

/Lars
--
Lars Fischer, fischer@iesd.auc.dk | It takes an uncommon mind to think of
CS Dept., Aalborg Univ., DENMARK. | these things.  -- Calvin
From: mcglk@cpac.washington.edu (Ken McGlothlen)
Newsgroups: comp.lang.c
Subject: Re: Problem with string processing.
Date: 5 Jan 93 08:58:33 GMT
Article-I.D.: yang.MCGLK.93Jan5005833
Distribution: usa
Organization: Dubious.
NNTP-Posting-Host: yang.cpac.washington.edu

Roy M. Silvernail (roy%cybrspc@cs.umn.edu) writes:
+----------
| [regarding the C statment:  while (*ptr++ = *str++);  ]
|
| (nice touch, BTW) How does this differ from 'strcpy(ptr, str)' besides the
| function call overhead?
+----------

It doesn't.  In fact, that's often how strcpy() is implemented.

+----------
| Assuming a large enough string for the append, and low-high byte ordering,
| would this work?
|
| strcat(str,(char *)&ch);
+----------

Well, it would work *sometimes*.  Remember that strcat() expects two pointers
to ZERO-TERMINATED strings.  If what was stored in ch was immediately followed
by a zero byte ('\0'), then it *would* work.  But ch is stored wherever the
compiler wants to store it, and it could be followed by *anything*, which means
that you could get a heck of a lot more characters on the end of str than you
bargained for.

				---Ken McGlothlen
				   mcglk@cpac.washington.edu
				   mcglk@cpac.bitnet
From: z_harbergt@ccsvax.sfasu.edu
Newsgroups: comp.lang.c
Subject: Help: VAX C struct timeb_t ?
Date: 4 Jan 93 21:20:06 CST
Organization: Stephen F. Austin State University

 I wrote some simple timing routines for my PC using Turbo-C and wanted
 to port them to the VAX but ran into a difference between Borland's
 interpretation of UNIX's ftime() and DEC's.  I do not have access to the
 VAX documentation until after 1-14 and the online help is weak; basically
 I need to now the contents of the VAX C struct timeb_t (which is defined
 as timeb in Turbo-C).

 Thanks in advance for any and all help,

 Greg z_harbergt@ccsvax.sfasu.edu
Newsgroups: comp.lang.c
From: dfuller@portal.hq.videocart.com (Dave Fuller)
Subject: Re: NH-- > NH
Organization: VideOcart Inc.
X-Newsreader: Tin 1.1 PL3
Date: Fri, 8 Jan 1993 22:43:10 GMT

keith@torme.sharebase.com (Keith Chambless) writes:
: In article <C0JMw6.680@netnews.jhuapl.edu> bandy@netnews.jhuapl.edu (Mike Bandy) writes:
: >
: >So what you're saying is that NH > NH.  I don't believe it.  Your 
: >compiler (or your logic) has some serious problems.
: 
: 
: Weird. Mine (Solbourne w/OS/MP 4.0) works the same:
: 
: 	if (nh-- > nh)
: 	  printf("nh-- > nh = true\n");
: 
: prints true. I don't understand.
: 

  If the left side is evaluated before the right side it will happen.
nh-- has a value of nh because the -- takes place after expression evaluation.
The -- will happen and then the right side of the expression will be evaluated.
It will have a value of nh. However, nh at this point contains a value that is
1 less than the left hand side of the expression. 

Dave Fuller
dfuller@portal.hq.videocart.com

Newsgroups: comp.lang.c
From: lipson@dms.agames.com (Pete Lipson)
Subject: Re: Unsolveable bug
Organization: Atari Games Corporation
X-Newsreader: TIN [version 1.1 PL6]
Date: Mon, 4 Jan 1993 18:13:06 GMT

Mike Bandy (bandy@netnews.jhuapl.edu) wrote:
: markh@csd4.csd.uwm.edu (Mark) writes:
: 
: >   I've run into an unsolveable bug.  The bug comes from no visible error, it
  - i hope there's no such beast.... :)

: >   It appears on the DOS port of the program and causes the machine to crash
: >immediately after a call to malloc().  The malloc call is the ANSI-compatible
 - which indicates damage to the heap links i suspect
: 
: Given your symptoms, I'd examine the PC's hardware for problems.  How
: does the PC behave under other memory intensive applications?
: 
  you could TRY a ram-test.  But i just had a similar problem that i caught
by substituting my own version of MALLOC.  I changed MALLOC (and FREE and
REALLOC) to allocate two extra longwords. I filled the longword at the
beginning and at the end of the allocated block with a recognizeable pattern
and returned the address of the SECOND longword to the program.  When FREE
or REALLOC is called, it checks the integrity of the validation words and
complains by exiting to the debugger. Usually that's enough information to
spot which array is having its bounds exceeded (the usual way of trashing
a heap).  You could extend this scheme to link together all your allocated
blocks and on each invocation of MALLOC you could test the checkwords; you
could even add specific 'test' sprinkled through your program to narrow
down your search.
  If you want, i can E-mail you a sample file containing MALLOC,REMALLOC and
FREE.
-- 
  /V\
-/@-*\- Peter Lipson <-- lipson@agames.com   or   netcom!dms!lipson
 \_o_/  Milpitas, CA <-- Atari Games
   U
From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
Newsgroups: comp.lang.c
Subject: Re: Borland Support: JD Powers AD is B.S.
Date: 7 Jan 93 17:04:10 GMT
Organization: Texas Instruments Inc

In <6JAN199317173570@utkvx3.utk.edu> drevik@utkvx3.utk.edu (Drevik, Steve) writes:


>Save yourself the long distance charges.  Better yet, save
>yourself money and time and buy something else!!!

Like what?


-- 
"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,comp.lang.c++
From: brown@NCoast.ORG (Stan Brown)
Subject: Re: Dynamic Mem Help
Organization: Oak Road Systems, Cleveland Ohio USA
Date: Sat, 9 Jan 1993 14:11:07 GMT

In article <rfries.159@sceng.ub.com> rfries@sceng.ub.com (Robert Fries) writes:
>In article <93007.230524U10139@uicvm.uic.edu> T J Furstenau <U10139@uicvm.uic.edu> writes:
>... stuff deleted
>>    char *str = NULL;
>
>>    /* allocate memory for string */
>>    str = calloc(10, sizeof(char));
>... more stuff deleted
>>I get the following error message:
>
>>Error D:\BC\BIN\WORK\NONAME00.CPP 10: Cannot assign 'void near*' to
>>'char near*' in function main().
>
>C++ and ANSI C do fairly strict type-checking, and since
>malloc() and calloc() are used to allocate memory for
>different types of objects, they are declared to return
>(void *), which is sort of a generic pointer.
>
>You'll have to use an explicit cast of this value to 
>assign it to a variable of type 'char *', e.g.:
>	str = (char *)calloc(10, sizeof(char));
>	       ^^^^^^	

Red herring!

From the error message, I presume that the original questioner is
programming in C++.  It was not the best idea to post this question to
both comp.lang.c and comp.lang.c++, since this is one of the areas where, 
it appears, C++ differs from C.  People will be posting followups from
their newsgroups and not say whether they're talking C or C++.

I can't speak for C++, but the program is a correct C program with
respect to the pointer assignment.  (To be an ANSI C program, it should
include stdlib.h not alloc.h.) 

In ANSI C, void* is assignment-compatible with a pointer to any type of
object, so the cast is unnecessary.  Reference:  ANSI Standard sec
3.2.2.3 (ISO section 6.2.2.3, I believe).

-- 
Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
Cleveland, Ohio, USA

"Life!  Don't talk to me about life!"
From: scjones@thor.sdrc.com (Larry Jones)
Newsgroups: comp.lang.c
Subject: Re: Problem with string processing.
Date: 6 Jan 93 17:43:26 GMT
Distribution: usa

In article <811@ulogic.UUCP>, hartman@ulogic.UUCP (Richard M. Hartman) writes:
> If there were a decent way of getting the string length w/o
> counting all the bytes then direct support for strcpy() could
> be done easily.  Are there any CPUs that have a single-instruction
> way of saying "find the next 0 byte & tell me how far it was from here"?

Of course -- everyone's favorite example of a CISC machine, the good
old DEC Vax has the Locate Character (LOCC) instruction that locates
the next occurrence of any single character (as well as a whole bunch
of other character manipulation instructions); the Intel x86 family has
the Scan String (SCAS) instruction which can do the same thing; and
even the venerable IBM 360/370 family of CPUs have a Translate and Test
(TRT) instruction that locates the next occurrence of an character from
a set.

Of course, it's not clear that any of these instructions are actually
faster than the equivalent loop of primitive instructions and a good bit
of historical precedent indicates that they are probably slower.
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
larry.jones@sdrc.com  or  ...uunet!sdrc!larry.jones
Why can't I ever build character in a Miami condo or a casino somewhere?
-- Calvin
Newsgroups: comp.lang.c,comp.lang.pascal
From: tmc@spartan.ac.BrockU.CA (Tim Ciceran)
Subject: Pattern Matching for Spelling Correction
Organization: Brock University, St. Catharines Ontario
Date: Thu, 7 Jan 1993 05:46:51 GMT

I'm currently working on the front-end to an information retrieval
package and would like to incorporate a facility to provide for
spelling correction. Does anyone have any recommendations for an
efficient pattern matching algorithm which could be used in this
capacity? 

The dictionary is rather large (but static) and I would prefer having
the option to search the entries either on disk or through a table
in memory. 

Any insights or references would be especially helpful.

Thanks in advance,

TMC

Newsgroups: local.unix.help,comp.lang.c
From: kaarts@ccu.umanitoba.ca (Kenneth John Aarts)
Subject: Using C to read Fortran Files
Organization: University of Manitoba, Winnipeg, Manitoba, Canada
Date: Wed, 6 Jan 1993 16:48:02 GMT


I have a fortran program that does essentially

	open(unit=1,"test",status='new')
	write(1,10) 'cArt'
10	format(a4)
	end

and then a C program that reads it:

	int d1,d2,d3,d4,d5;
	FILE *fp;
	fp=fopen("test","r");
	fscanf(fp,"%c%c%c%c%c",&d1,&d2,&d3,&d4,&d5);
	printf("%d %d %d %d %d\n",d1,d2,d3,d4,d5);

The output of the C program is:

  10  65  114  116   13

  LF  A    r   t    CR

However, a fortran program reading the test program does see cArt.

How do I get C to find the c in cArt?

Thanks,

Ken
From: champion@cch.coventry.ac.uk (Alun)
Newsgroups: comp.lang.c
Subject: Re: Need help with string arrays
Date: 5 Jan 93 10:17:13 GMT
Organization: Coventry University, Coventry, UK.

In article <1992Dec27.232512.22474@news.ysu.edu> ah017@yfn.ysu.edu (John B. Lee) writes:
~
~In a current program that I am writing I have an array declaration
~that looks like this:
~
~char names[][4];
~
~How would I use the gets() function to put a string into this array.
~Am I declaring the array correctly to receive five strings?  << This
~is what I'm trying to do.
~

No you are not declaring it correctly.
char names[][5];
/* Declares an array of 5 (from 0 to 4) arrays of characters */

Personally I would declare this as
char *names[5];

but you must remember that gets() is not good - it does nothing about bounds
checking. If you type a name longer than the allocated memory then gets() will
corrupt your program.

Use fgets

Example: (Not a very good one)

int i;
char *names[5];                         /* 5 Names */
char buf[MAX_NAME_SIZE + 1];            /* fgets() appends a '\0' */

for(i = 0; i < 5; i++) {
    fgets(buf, MAX_NAME_SIZE, stdin);
    if(buf[strlen(buf) - 1] == '\n')
        buf[strlen(buf) - 1] == '\0';
    names[i] = malloc(sizeof(char) * (strlen(buf) + 1)); /* Test! Test! Test! */
    strcpy(names[i], buf);
}
    

Hope this helps

  -Alun
  
-- 
  *I'm as bad as the worst - but thank God(?) I am as good as the best.*
    *People who think they know everything annoy those of us that do.*
A.Champion                |  That's an interesting point, in the sense of
(champion@uk.ac.cov.cch)  |    being very not interesting at all. - The Liar
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c
Subject: Re: Problem with string processing.
Date: 7 Jan 93 23:28:12 GMT
Distribution: usa
Organization: negligable

What I was after was the rough equivilent difference between (Intel)

	MOVSW	src,dst

and a loop w/ 

	MOV ax,src 
	MOV dstax

(so sue me if my assembly is wrong...)  The thing is that, yes
each byte does have to get moved, but the one instruction moves
'em a heck of a lot quicker than the loop of separate instructions.

I was postulating a similarly enhanced "search for byte from here"
instruction.

OF COURSE all the bytes have to be looked at, but if the CPU
"knows" how to do this in microcode, then you don't have to
waste CPU time loading all those instructions in the loop
over and over again, you just have to load the data.


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
And the men who hold high places	|
must be the ones who start		|	-Richard Hartman	
to mold a new reality			|	hartman@uLogic.COM
closer to the heart!			|
Newsgroups: comp.lang.c
Subject: C command set
From: towen@.cse.utoledo.edu (tom owen)
Date: 5 Jan 93 16:32:18 EST
Reply-To: towen@.cse.utoledo.edu
Distribution: world
Organization: The University of Toledo
Keywords: A professor I work for is looking for and abbreviated listing of C commands. 
 I assume that he is looking for ANSI C.  If any one out there knows if or  
 where such an animal exists either post it here or E-mail me.  Thanks in advance.

  Tom Owen--- no one tells the truth on purpose.  towen@maine.cse.utoledo.edu
From: jos@and.nl (Jos Horsmeier)
Newsgroups: comp.lang.c
Subject: Re: Interesting bug
Date: 7 Jan 93 09:24:20 GMT
Organization: AND Software BV Rotterdam

In article <8GJ037B@math.fu-berlin.de> rene@hamel.uucp (Rene Mueller) writes:
|In article <92353.203941SML108@psuvm.psu.edu>, <SML108@psuvm.psu.edu> writes:
||> I had a program with code like
||> 
||> void routine (x)
||> int *x;
||> {
||>   int x;
||> }
||> 
||> My compiler did not trap this as an error...  Shouldn't it?  Or at least
||> give a warning?

|No, it should'nt give even a warning...
|Cause you open a new block with '{', and inside a new block you can define a NEW
|variable with an 'old' name...
|That mean that you will see the functionparameter right after the closing bracket
|'}', but that's too late....

Sorry, you're wrong. The compiler should start whining and set this program
on fire 'till its dead and gone. This is definitely an error. Read the
ANSI C standard: 3.1.2.1 Scope of identifiers:

`If the declarator or type specifier that declares the identifier appears
inside a block or within the list of parameter declarations in a function
definition, the identifier has block scope, which terminates at the } that
closes the associated block.'

Both identifiers `x' in the code above have the same block scope, so this
is an invalid redefinition of the identifier `x'. The compiler should not
only give a warning, it should give an error message.

kind regards,

Jos aka jos@and.nl
Newsgroups: comp.lang.c
From: rfries@sceng.ub.com (Robert Fries)
Subject: Re: C if else statements HELP
Organization: Ungermann Bass
Date: Fri, 8 Jan 1993 17:31:13 GMT

In article <1993Jan8.160740.22055@magnus.acs.ohio-state.edu> ctoth@magnus.acs.ohio-state.edu (Christopher M Toth) writes:

>       Hi! I just started learning C and have run into problems with
>'if' and'else' statements. I have a program that I am *trying* to write. The
>basic format is:

>       printf ("which do you choose?");
>       scanf("%d", &n);
>       choice#1
>       choice#2
>       choice#3
>       choice#4

>       if choice #1
>               printf.....
>       if choice #2
>               printf.....
>       if choice #3
>               printf.....
>       if choice #4
>               printf.....

>       I want the program to goto the approiate section when the user
>inputs either 1,2,3,or 4. ANy help would be greatly and mostly appreciated! :)

>Thanks!

>-- 
>Christopher M. Toth             | "... We travel in the dark of a new moon
>The Ohio State University       | A starry highway traced on the map of the sky
>Columbus State                  | Like lovers and heroes,
>CIS/History/Classics/ect..Major | Lonely as the eagle's cry..." -Peart

This looks like a good place to use 'switch'.

example:
	switch(choice)
	{
		case '1':
			.. do something;
			break;
		case '2':
			.. do something;
			break;
		default:
			printf("unexpected input\n");
			break;
	}

The break statement following the default case is optional, but harmless.
It's considered good style, though, in case something is added after the 
default, at some future time.

The value tested in a switch() statement must 
be of integer type,which fits your example.

If strings are input, then you'll have to do it a bit differently. 
You'd use if...else constructs with a string compare function to achieve 
a similar effect.

Robert


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

DISCLAIMER:
    Opinions contained herein are my own, and are not necessarily those
    of Ungermann-Bass.
//////////////////////////////////////////////////////////////////////////
Newsgroups: comp.lang.c
From: dkeisen@leland.Stanford.EDU (Dave Eisen)
Subject: Re: Problem with string processing.
Organization: Sequoia Peripherals, Inc.
Date: Wed, 6 Jan 93 06:20:01 GMT

In article <1993Jan6.020420.25829@iitmax.iit.edu> matujos@elof.iit.edu (Joe Matusiewicz) writes:
>    The problem was most likely my use of calloc with one argument.  I
>first used malloc and forgot that calloc required 2 parameters, so I 
>accidentally forgot about that.   (But some of you might agree with me that
>the stupidest errors are usually the hardest to find).  Anyway, here is

This one should have been easy to find. If you had #included the
file <stdlib.h> which contains the prototype for calloc, your
compiler would have alerted you to your mistake.


-- 
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: ihsan@ferranti.com (jaleel ihsan)
Subject: Re: Program to convert .EXE to a "C" source file?  I really need one!!
Organization: Unix/Xenix Support Group
Date: Fri, 8 Jan 1993 18:41:36 GMT

In article <C0B6x5.DA6@ulowell.ulowell.edu>, mbrousse@cs.ulowell.edu (Marc Brousseau) writes:
>>>>Hello. 
>>>>	I am looking for a program that will take a .EXE or .COM file and
>>>>convert it into a "C" source file.  I saw one on one of the FTP sites today,
>>> [Stuff deleted]
>>> 	I am looking for a program of that nature too.  If someone knows 
>>> where one can be FTP'd I would appreciate E-Mail telling me.  
>>> 				Thanks,
>>> 				dutc0006@student.tc.umn.edu			
>>> 
>>I'd prefer a program that generates the RCS or SCCS archives the program was 
>>developed in, plus a makefile.  Architectural and design documents would be 
>>nice too.
>>----------------------------------------------------------------------------
>I want a printer that will run in reverse, taking in a document, and
>converting it to a word processor file. Word for Windows out of a
>newspaper would be nize.

Actually I have some old data tapes that were generated by an application
that has been lost.  I was wondering if there is a program that can read
the data and create the program that generated it.  Just the source code
would be fine, I can handle the compilation and linking.  No restriction
on language either, any commonly used language will do.
From: steve@dbaccess.com (Steve Suttles)
Newsgroups: comp.lang.c
Subject: Re: Borland Support: JD Powers AD is B.S.
Date: 8 Jan 93 04:36:55 GMT
Organization: Cross Access Corp., Santa Clara, CA
X-Newsreader: Tin 1.1 PL4

drevik@utkvx3.utk.edu (Drevik, Steve) writes:
: FYI directed towards future developers who are thinking
: about what C or C++ compliler to use....
: 
[ Borland bashing deleted ]

While I have no reason to doubt this article, there is another point of
view...

I installed Borland C++Pro v2.0 on my machine.  I paid full list
price (GULP) but I was told it was worth it.

I also bought an editor and a word processor at full price.

I don't use the other products, because the IDE editor is far
superior to those with fantastic reps, such as the Norton editor.
I don't even use the word processor (Volkswriter) because I'd
rather deal with the IDE than the headaches it invokes.  Of
course, for real pretty stuff, neither works...I use AMI pro for that.

I found out shortly after I paid for 2.0 that I could have gotten it
for far less...but I couldn't get a refund.  I was unhappy that I
spend money unnecessarily, but I never felt like I paid more than
what it was worth (those other products though, and those games
that hang my system!!!).

My only regret is the upgrade to 3.0 was too expensive.  I just
couldn't pay for it, regardless of the value.

I write software for my bread and butter, and have done so for 15
years.  I'm considered to be pretty good at it--I write O/S level
stuff, with compilers, linkers, and editors thrown in "in my spare
time".  I've had to replace some of DOS's utilities because they were
not robust enough (I wrote my own, using Borland's 2.0 C) and never had
occasion to call their customer support.

So I can't comment on the ability of their customer support group.
Maybe they just don't get enough practice?

PS:  It turns out that the most common problem with tested software
not working on someone else's machine is a difference in the
environment...and "vanillaizing" your autoexec is the correct first
step.  If duplicating the problem on another machine is necessary,
the correct step to follow that is to make sure you are using the
current rev of code.  I concur with Borland's estimation of steps
one and two.

Good job, Borland!  If only the $10 games that don't run were worth
$10, and the $1 PD stuff was all worth a buck!

sas
-- 
Steve Suttles                Internet:  steve@dbaccess.com      Dr. DCL is IN!
CROSS ACCESS Corporation     UUCP: {uunet,sgiblab}!troi!steve  Yo speako TECO!
2900 Gordon Ave, Suite 100   fax: (408) 735-0328              Talk data to me!
Santa Clara, CA 95051-0718   vox: (408) 735-7545   HA! It's under 4 lines NOW!
Newsgroups: comp.lang.c
From: raph@panache.demon.co.uk (Raphael mankin)
Subject: Re: Any hope for me..? 
Distribution: world
Organization: Solvfield Ltd.
Reply-To: raph@panache.demon.co.uk
X-Mailer: Simple NEWS 1.90 (ka9q DIS 1.19)
Date: Wed, 6 Jan 1993 21:28:30 +0000

When I employ programmers I prefer those with a degree in English or History
or Physics, or anything except CS. They tend to have more rounded knowledge
and don't think that they know it all.

My experience of CS graduates is that, by and large, they have read nothing
and know nothing that was not in their degree course.
-- 
Raphael Mankin			Nil taurus excretum