HDTenEightyP/NetNews huggingface dataset:
From: stern@mble.philips.be
Newsgroups: comp.lang.c
Subject: Re: Is it MY problem...or is it Borland's?
Date: 27 Jul 92 09:20:39 MEWT
Organization: MBLE , Brussels, Belgium

In article <1992Jul25.162844.18778@uwm.edu>, rca@csd4.csd.uwm.edu (Robert C Allender) writes:
> I'm VERY new to C, but I can usually hold my own by R(ing)TFM.  This is 
> different.  I've checked through Borland's FAX document catalog (I use 
> Borland's C++ 3.0, but I use the standard C mode), ALL the manuals, a few 
> 3rd party books on Borland C ... nothing.  Here's the problem:
> I initialize a char * in main() and pass it to a function that gets a string, 
> passing the address of the string back to main().  If I try to print the 
> string back at main(), it works.  I pass the char * to the next function, and
> I can print the string at the beginning of that function, but by the end of 
> it, the string is garbage.  If I then pass the value to main() and send it to
> yet aother function, the array is empty.  I can put checks in anywhere and
> find the strlen() to be correct at ANY of the points where it won't print, 
> but the values get corrupt and then dissappear.  What am I doing wrong?
> 
> Here's the boiled-down code...

[deleted]

> char * scrollbox(char,int,int);

[deleted]

> main() {
>   char drive, *c;
>     c = scrollbox(drive,61,10);  <---- This gets a directory, etc. 
>   
>   clear_half(c);                 <-- can print the array here BEFORE the end
> 				     of the function, else it's garbage.

This is a bug in your program:

As the string containing the directory is local to function scrollbox,
it is located on the stack. If you access it immediately after calling 
the function there are many chances that this value has not been modified
(it is obviously a non-standard side-effect); this is what happens here.
Once you call another function the stack is overwritten.

That's all folks

--  Marc Stern  <stern@mble.philips.be>
Newsgroups: comp.lang.c
From: cbbrowne@csi.uottawa.ca (Christopher Browne)
Subject: Re: initiaklizing union members
Organization: Dept. of Computer Science, University of Ottawa
Distribution: usa
Date: Thu, 23 Jul 92 14:30:08 GMT

In article <5391@dsacg3.dsac.dla.mil> nto0302@dsacg3.dsac.dla.mil (Bob Fisher) writes:
>From article <1708@toro.MTS.ML.COM>, by scott@toro.MTS.ML.COM (Scott Strool):
>| How can I initialize a struct that contains a union member.
>| If I have a struct as defined:
>| 
>| struct Row {
>| 	int Type;
>| 	union {
>| 		int ival;
>| 		char* sval;
>| 		} value;
>| 	};
>| 
>| how would i set value with a static declaration:
>| 
>| static Row r0 = { 0, 1234 };
>| static Row r1 = { 1, "string" };
>| 
>| This does not work!

Maybe if you get the structs to sign their union cards, you might have
better success.  Then head office would be able to properly deduct the
-- 
Christopher Browne
cbbrowne@csi.uottawa.ca
University of Ottawa
Master of System Science Program
From: elias@proxxi.se (Elias M}rtensson (proxxi))
Newsgroups: comp.lang.c
Subject: Re: About the 'F' in RTFM
Date: 26 Jul 92 17:53:18 GMT
Organization: proxxi

stephen@eggneb.astro.ucla.edu (Stephen Schimpf) writes:

>In article <1992Jul20.144048.15503@ugle.unit.no> robert@solan.unit.no (Robert Schmidt) writes:
>>fucking?

>YES! Finally! It's amazing to me how long it took for someone to write the
>word. It's just a WORD. Restrict the words we can use and you restrict what
>we can think. RTM just doesn't express the same feeling that RTFM does.

#define fucking fine

>Stephen

###################
# Elias Martenson #
# elias@proxxi.se #
###################
Newsgroups: comp.lang.c
From: tindall@casbah.acns.nwu.edu (Mike Tindall)
Newsgroups: comp.lang.c
Subject: redirecting stdout
Date: 25 Jul 92 18:47:24 GMT
Organization: Northwestern University, Evanston Illinois.


	How can  I return stdout to printing to the screen after  redirecting
it to a file using out_file=freopen("fname","w",stdout)?
From: alpha@wyvern.twuug.com
Newsgroups: comp.lang.c
Date: 18 Jul 92 00:12 MDT
Subject: Re: unsigned long to long without lossa
Nf-ID: #R:brself.711346221@hal:-680706142:1992Jul17.201215.19749@wyvern.tw:498465169:001:2072
Nf-From: wyvern.twuug.com!alpha    Jul 18 00:12:00 1992


brself@hal.gnu.ai.mit.edu (Ben Self) writes:
: 
: Can anyone please tell me a portable (one which does not step on either
: the ANSI or POSIX standards) way to preserve the bit order and precision
: of an unsigned long that has to be crammed into a variable of type long.
: 
: I need to do this for passing a message to an external process so the 
: actual value does not matter as long as it can be converted back to 
: the original state.
: 
: Example:
: 
:     #define MESSAGE_REQUEST {( some very long unsigned number )}
: 
:     foo ()
:     {
:        struct Message message;
:        unsigned long int ulong_val = MESSAGE_REQUEST;
:     
:     
:        message.long_val = ulong_val;
: 
:      ... 
: 
: I know that ANSI treats unsigned long as wider type than long and if
: mixed all values are promoted to unsigned long.  It therefore stands
: to reason that precision will be lost when a value is demoted from
: unsigned long to long.  This is not acceptable.
: 
: I know they both have the same size; surely there must be a way to
: assure there is no loss of information in a portable way.
: 
: 
: I appreciate *any* help that can be given on this matter.

Most of my posts generate flames from 'knowledgable' readers and
alternatives to any suggestions.  So here goes..

Historically, 'unsigned long' has been supported by the language
but not by the implementation.  This has to do with the complexity
(in the implementation) of treating the two differently.  Really, 
why should we treat 'unsigned long'?  Nobody needs an integer bigger
that 2 billion, surely.  

If the ANSI standard provides different sizes for 'long int' and 
'unsigned long int' it is news to me.  I would guess that all
implementations will have them the same size in any case.

Assuming the objects of these types are the same size, there is no
problem assigning either type to the object.  You must only take care
to 'cast' the result properly when you use it the next time.

Use the same care that you would with 'int' and 'unsigned int'.
-- 
Joe Wright  alpha@wyvern.twuug.com    

Newsgroups: comp.lang.c
From: wmsg4931@uxa.cso.uiuc.edu (Walter M. Seiler)
Subject: Numerical Recipes in C
Summary: Numerical Recipes in C code
Organization: University of Illinois at Urbana
Date: Tue, 21 Jul 1992 18:15:59 GMT

I have Numerical Recipes in C book and the fortran
book and the fortran disk.  But was wondering if
anyone out there could assist me in getting the
C and/or pascal code segments.

Any help would be appreciated.

Walt
email: walt@uiuc.edu
From: bob@comlab.gatech.edu (Bob Baggerman)
Newsgroups: comp.lang.c
Subject: Re: popper - UC Berkeley Post Office Protocol Server, __res
Date: 22 Jul 92 21:23:25 GMT
Organization: Georgia Institute of Technology

In article <54780@mentor.cc.purdue.edu> brian@brazil.psych.purdue.edu (Brian Berndt) writes:
>
>ld: Undefined symbol 
>   __res 
>
>Does anyone know what this sysmbol might be, it is not defined in any of
>the c source files.

_res is used in only one place, "pop_init.c".  _res is defined in "resolve.h"
and is used in the DNS name resolving code.  The actual variable lives in
the "resolv" library.

>Has anyone set up popper on their system?  Anyone seen this problem?

The first time I built popper everything went fine.  Later I had occasion to
rebuild it and I got the same errors you did.  I don't really know why it 
worked the first time and bombed the second time but the solution for me was
to explicitly reference the "resolv" library in the Makefile.  Mine looks like:

CFLAGS          =       -O -lresolv -DBIND43 -DHAVE_VSPRINTF

Note I have added the "-lresolv" library reference.  It has also been reported
that removing the "-DBIND43" definition will produce the desired results.  In
this case about 25 lines of code including the offending statement are replaced
with one simple line and all of a sudden the world is good again.  I'm still
confounded though as to why all this worked the first time for me but not the
second.  Oh well.

Bob



--
Bob Baggerman                         !  bob.baggerman@gtri.gatech.edu
Communications Laboratory             !  bob@comlab.gatech.edu
Georgia Tech Research Institute       !  qseclrb@prism.gatech.edu
Atlanta, GA  30332  USA               !  404-894-3525
Newsgroups: comp.lang.c
From: af458@yfn.ysu.edu (Jon K. Salmon)
Subject: Re: gethostnamae(), novice question...
Organization: Youngstown State University/Youngstown Free-Net
Date: Sun, 26 Jul 1992 02:47:47 GMT


> #include <stdio.h>
>
> main() {
>   char *host[64];
>   gethostname(host,sizeof host);
>   printf("%s\n",host);
> }

> This program gets the hostname as 'mercury.ncat.edu'. What's the decent
> way/s to strip off the .ncat.edu part? I know how to do that by sed. The
> solution should be general, I mean should be applicable to any hostname with
> domain name in it.

How about this:

  if (strchr(host,'.') != NULL)
    *(strchr(host,'.')) = 0x00;

It will simply put a terminating null whereever the first
period, if any, is.

-- Jon
Newsgroups: comp.lang.c
From: levine@symcom.math.uiuc.edu (Lenore Levine)
Subject: Full Screen Text Editor Recommendations (for PC-Compatible)
Organization: University of Illinois at Urbana
Date: Sun, 26 Jul 1992 19:41:38 GMT

Can anyone recommend a full screen (80 x 25 lines rather than 79 x 22)
text editor, that is not as expensive as Brief?
Newsgroups: comp.lang.c
From: mat@mole-end
Subject: Re: About the 'F' in RTFM
Organization: :
Date: Wed, 22 Jul 1992 20:39:16 GMT

In article <1992Jul19.162408.25874@amhux2.amherst.edu>, twpierce@amhux1.amherst.edu (Tim Pierce) writes:
> In article <1992Jul17.202448.19848@wyvern.twuug.com> alpha@wyvern.twuug.com (Joe Wright) writes:
> 
> >Proposed change to 'standard' practice.  'RTFM' is now 'RTM'.
 
> Robert Tappan Manual?
 
> >The 'F' does not relate to any known adjective for Manual.
 
> Um, maybe it doesn't to you, but to generations of Unix programmers
> out there ... :-)

Oh, you mean the fuddlin' manual!
-- 
 (This man's opinions are his own.)
 From mole-end				Mark Terribile

 uunet!mole-end!mat, Somewhere in Matawan, NJ
Newsgroups: comp.lang.c
From: exujuyu@exu.ericsson.se (Junwen Yuan)
Subject: "fork"/"vfork" on the SUN
Reply-To: exujuyu@exu.ericsson.se (Junwen Yuan)
Organization: Ericsson Network Systems
Date: Fri, 24 Jul 1992 20:51:52 GMT

Hi,

Is there any other easy way, other than "vfork()", to let a forked
child share the same data object as its parent?

Thanks

--Junwen
--
=====================================================
Junwen Yuan                   exujuyu@exu.ericsson.se
Ericsson Network Systems, Inc
=====================================================
Newsgroups: comp.lang.c
From: amorgan@Xenon.Stanford.EDU (Crunchy Frog)
Subject: Re: Variable length records
Organization: Computer Science Department, Stanford University.
Date: Mon, 27 Jul 1992 21:45:17 GMT

wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:
>gurgle@netcom.com (Pete Gontier) writes:
>>typedef struct
>>{
>>	short   count;
>>   float   data[ ];
>>}
>>foo;
>>
>>I refer to the second member as an "open array." Its behavior is this:
>>	o  it may appear only as the last member of a structure
>>	o  it does not contribute to the value returned by sizeof(foo)
>>   o  it may be addressed, of course, with an arbitrary index
>
>My gcc 2.2.2 under Linux doesn't seem to support it, at least with the
>default options:
>
>	foo.c:3: field `data' has incomplete type

But it *does* accept

typedef struct
{
	short count;
	float data[0];
} foo;

I have not *actually* checked this, but it is listed in the manual
as a GNU extension, for the reasons others have discussed.

C Frog
From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
Newsgroups: comp.lang.c
Subject: Re: Pointers to freed memory
Date: 30 Jul 92 18:09:08 GMT
Reply-To: volpe@ausable.crd.ge.com
Organization: GE Corporate Research & Development

In article <3179@dozo.and.nl>, jos@and.nl (Jos Horsmeier) writes:
|> In article <1992Jul29.205834.11308@hubcap.clemson.edu> mjs@hubcap.clemson.edu (M. J. Saltzman) writes:
|> |I know that a pointer to freed memory should never be dereferenced, 
|> |but is it standard-conforming to assign or do arithmetic with such
|> |pointers?
|> |
|> |The application is a routine to free the elements of a circular list.
|> |Since I have a count of the elements, I can simply run a pair of pointers
|> |around the list, like so:
|> |
|> |	for ( p = head, i = 0;  i < n;  i++ ) {
|> |		q = p;
|> |		p = p->next;
|> |		free(q);
|> |	}
|> |
|> |The question comes up because on the last iteration, p->next points
|> |to the element freed in the first iteration.  Do I need to break the
|> |circle before I start the loop? Or am I just being paranoid after the 
|> |discussion of pointers to invalid array elements?
|> 
|> Erm, yes, I hate to say it, but you're getting paranoid ;-) 

I'd say that's true for most real compilers, but...

|> 
|> As long as you do not dereference such a pointer (as you indicated
|> yourself,) everything is fine.  If pointer q contained a valid pointer

I disagree that this will always be true. There is nothing to prevent
an implementation from trapping assignments of invalid addresses to
pointer variables. I wouldn't be surprised if a debugging C interpreter
(ala Saber) did this someday. 

|> value _before_ the call to free(), it'll contain a valid pointer value
|> _after_ the call. In the last iteration, the value p->next points to
|> a location in memory where the first element of the list _would have
|> been_ if it weren't freed in the first iteration. And, again, if you
|> don't dereference that pointer value, everything is safe and sound.
|> 
|> kind regards,
|> 
|> Jos aka jos@and.nl

-- 
==================
Chris Volpe
G.E. Corporate R&D
volpecr@crd.ge.com
From: huynh@falcon.navsses.navy.mil
Newsgroups: comp.lang.c
Subject: converting C 'for' to PASCAL 'FOR'
Date: 28 Jul 92 20:19:37 GMT
Organization: NSWCCD, Naval Ship Systems Eng Sta, Phila PA

Hello,

I am curious if there is a way to translate the "C" for(i,start,last,incr)
statement into the PASCAL FOR i = start to last DO (* incr = 1 *).
I am interested in doing this using the #define statement.
Has anyone done this? Help is much appreciated.

Here is an example of how the "C" 'for' statement is translate into FORTRAN
'DO':
#define DO(i,start,last,incr) for((i)=(start);(i)<=(last);(i)+=(incr))

Thanks in advance.

Nhan H. Huynh, PASCAL 's structure 's best
Science and Engineering Aprrentice, Naval Base, Philadelphia PA.
Newsgroups: comp.lang.c
From: darcy@druid.uucp (D'Arcy J.M. Cain)
Subject: Re: Hungarian notation
Date: Fri, 24 Jul 1992 14:25:54 GMT
Organization: D'Arcy Cain Consulting

[Apologies if you see this twice - I think it failed the first time]

aduncan@rhea.trl.OZ.AU (Allan Duncan) writes:
>From article <1992Jul20.084316.15691@druid.uucp>, by darcy@druid.uucp (D'Arcy J.M. Cain):
>> On the other hand, a properly prototyped program using a modern compiler
>> will tell you when you are using a variable incorrectly and in the above
>> example will simply do the promotion silently.  This means that you don't
>> even have to know what filepos is other than that it is a variable holding
>> the position in a file.  You can deal with the abstract concept without
>> getting involved in the details of the bits that are used to implement it.
>
>This reliance on a compiler is no better than a journalist relying on a
>spelling and grammar checker.  It is getting very common now to see

There is nothing wrong with relying on your tools to help you.  Of course
you can't rely *solely* on your tools but where is that not true?  If a
journalist or other writer were to put their work through a checker before
or after manually checking that would be better than manually checking
alone.  One may as well say that reliance on your own ability as a sole
means of catching coding errors is irresponsible.  Use the tools.

-- 
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: dbushong@wang.com (Dave Bushong)
Subject: Re: About the 'F' in RTFM
Organization: Wang Labs, Lowell MA, USA
Date: Thu, 23 Jul 92 02:10:24 GMT
Followup-To: alt.flame

amorgan@Xenon.Stanford.EDU (Crunchy Frog) writes:

>In article <l6rbffINN8hu@appserv.Eng.Sun.COM> 
>  limes@ouroborous.Eng.Sun.COM (Greg Limes) writes:
>>In article <1992Jul17.202448.19848@wyvern.twuug.com> 
>>  alpha@wyvern.twuug.com (Joe Wright) writes:
>>> Proposed change to 'standard' practice.  'RTFM' is now 'RTM'.
>>> The 'F' does not relate to any known adjective for Manual.
>>> 'Read The Manual' should suffice.
>>
>>When some bonehead calls you up for the third time in an hour asking
>>questions the he can find in Section I of the Unix Programming Manual
>>or (worse) in the READ ME FIRST!!! document, telling him to RTM just
>>does not have enough emotional impact.

>Indeed, I sometimes use RTMFM.  In extreme cases I even put an A at the end.

Would 'A' be correct, or possibly instead, something hyphenated?  Are
we close to venturing outside the bounds of this newsgroup?  Perhaps
some of us are getting "RTFAQA-H" messages?  Maybe I will, also?


-- 
==========================================================================
Dave Bushong, KZ1O@K1UGM.MA         +    No .sig, no tattoo, 
Wang Laboratories, Inc.             +        no bald spot, no nothin!!
Internet: dbushong@wang.com         +-------------------------------------
Project leader, OCR Products        + (reserved for future expansion)
From: cliveg@cix.compulink.co.uk (Clive Grace)
Newsgroups: comp.lang.c
Subject: Books for sale
Date: 24 Jul 92 17:30:00 GMT
Reply-To: cliveg@cix.compulink.co.uk


I'm clearing out my entire collection of about 200 computer books -

many of which are either language-based, OS based or PC based... if

you would like a list, then email me on: cliveg@compulink.co.uk, and

I shll mail you a list with a contact number. Most books are around

#10 each I'd prefer selling them to people in the UK and Eire as US

postal charges can be prohibitive, but obviously I can sell to anyone

wanting a particular book.



These are all virtually unused. I have a job that involves buying

certain books, studying them and approving them for specific

companies and then doing a write-up - as a result, these books are

pristine in all cases - not scribbled in or dog-eared (i'm nice like

that).



Bulk orders are particularly welcome...



Clive Grace



cliveg@compulink.co.uk

cliveg@compulink.uucp
From: adam@castle.ed.ac.uk (Adam Hamilton)
Newsgroups: comp.lang.c
Subject: Variable length records
Date: 24 Jul 92 14:04:33 GMT
Organization: Edinburgh University


	During my last spell at teaching C, I was asked what support C
could give for variable length records.  (Not variant records which I can
do with a union).  I was unable to answer the question, so promised to
seek help (this means you).
	I welcome mail and postings.  If the answer is in the FAQ, I also
apologise and will someone please mail it to me.
		Adam
P.S.  I already know that Unix will have a problem with variable length
records since it doesn't know about records.  Nevertheless, if anyone knows
of an attempt to solve this I will be grateful to hear about it.

	Thanks in advance.
From: jmann@vineland.pubs.stratus.com (Jim Mann)
Newsgroups: comp.lang.c
Subject: Re: learning C?
Date: 29 Jul 92 13:40:33 GMT
Reply-To: jmann@vineland.pubs.stratus.com

In article <1683393E.RJONES1@ua1vm.ua.edu> RJONES1@ua1vm.ua.edu (Bart  
Jones) writes:
> 
>    What advice would you all give to a (very) novice who wants to learn  
C
> on the Mac?  Where would I start, and with what?  Books?  Reference?   
Programs,
> etc....  Any help or advice would be appreciated.
>  

There is a very good book called the Macintosh Programming Primer,
though I don't have it with me and don't remember the author.  A book
like this is essential for really learning the Macintosh implementation
of C.

If you are also new to C (and not just the Mac) you'll also need
a C textbook.  If you are a programmer and just want to quicly pick
up C syntax, The C Programming Language by Kernighan and Ritchie
is good (though a bit too terse for my tastes).  If you aren't 
a programmer already, or if you don't like a books as terse as
K&R, either the New C Primer Plus (Waite and Prata) or Programming
in ANSI C (Kochan) are good.

--
Jim Mann       jmann@vineland.pubs.stratus.com  Stratus Computer
Newsgroups: comp.lang.c
From: strachan@bilbo.cs.uct.ac.za (Craig Strachan)
Subject: IO
Organization: Computer Science Department, University of Cape Town
Distribution: all
Date: Thu, 30 Jul 1992 10:17:01 GMT


Help,
does anybody know how to assess the Comm.port on an IMB.pc,
using C++.
ie peek, poke in basic
It is rather urgent, I only want to send a pulse to a pin.

+---------------------+-------------------------------------------------+
|          ^          |       FROM: Craig Strachan                      |
|        -----        |	      strachan@bilbo.cs.uct.ac.za               |
|      /       \      +-------------------------------------------------+
|     \ O    O  /     |      2nd year Bsc.Eng (Elec,Com.sci major)      |
|       \|| ||/       |              & part-time musician               |
|        |\ /|        |  ( co-founder of the perfect people's society ) |
|        || || hello! +-------------------------------------------------+
|        \/ \/        |    ( also part-time walrus & court jester )     |
+---------------------+-------------------------------------------------+
--
+---------------------+-------------------------------------------------+
|          ^          |       FROM: Craig Strachan                      |
|        -----        |	      strachan@bilbo.cs.uct.ac.za               |
|      /       \      +-------------------------------------------------+
Newsgroups: comp.lang.c
From: eystein@smyril.fi.uib.no (Eystein Dugstad)
Subject: Wanted: lib file for Borland c and National Instruments' pc-lpm-16
Organization: University of Bergen, Norway
Date: Sat, 25 Jul 92 16:39:45 GMT

I would like to make a program in Borland C to operate my adc board  
pc-lpm-16 from National Instrument, and I therefore need a lib file. (I  
have it for Microsoft c)

Please post or email an answer

Eystein Dugstad
University of Bergen, Norway
Newsgroups: comp.lang.c
From: bz099@cleveland.Freenet.Edu (Robert W. Young)
Subject: Re: About the 'F' in RTFM
Organization: Case Western Reserve University, Cleveland, Ohio, (USA)
Date: Thu, 30 Jul 92 12:26:02 GMT


The 'F' doesn't relate to manual... I've got some good (depends on
your sensabilities) words and some interesting words.
 
You can insert all the swearing or pseudo-swearing (i.e. "flipping")
"F"s but how about:
flamboyant -- too much manual for too little product
fine -- darn good manual (this means you wrote the manual...)
flowery -- some professional language specialist (gotta be a word for
           that) was hired to put too many adjectives and adverbs in
fluffy -- manual says a lot, but nothing about the product
French -- it lost something in the translation...

There are several more pages of "F"s in just my Random-House Basic
Speller/Divider.  RTFM is a good and useful thing.  

Robert Young    bz099@cleveland.freenet.edu
                rwy@matt.ksu.ksu.edu
Newsgroups: comp.lang.c
From: shulick@navajo.ucs.indiana.edu (Sam Hulick)
Subject: NEVERMIND! (was strstr() problems)
Originator: shulick@navajo
Reply-To: shulick@navajo.ucs.indiana.edu
Organization: Vallen Software
Date: Thu, 23 Jul 1992 23:36:07 GMT


Nevermind, I found the problem.  It seems that SAS/C suddenly decided to
define strstr() themselves, and theirs was taking precedence over mine.
Their strstr() returns a (char *), mine returns (int).  Problem solved.

-- 
Sam Hulick  ///  E-mail: shulick@indiana.edu (including NeXT mail)
------------------------------------------------------------------------
  "The pen is the mouth and the paper is the soon-to-be-wise one."