HDTenEightyP/NetNews huggingface dataset:
From: misar@rbg.informatik.th-darmstadt.de (Walter Misar)
Newsgroups: comp.lang.c
Subject: Re: Preprocessor question
Keywords: Preprocessor, string
Date: 26 Jan 93 19:50:18 GMT
Organization: TH Darmstadt
NNTP-Posting-Host: rbhp58.rbg.informatik.th-darmstadt.de

In article <mick.728072797@picus>, mick@dcs.bbk.ac.uk (Mick Farmer) writes:
> Hi,
> 
> Karim asks how to get a preprocessor macro recognised inside
> a string.  The answer, at least in ANSI C, is to use the
> stringising operator and string concatenation:
> 
> #define JUNK 50
> static char *junk = #JUNK " ways to leave your lover"
                      ^^^^^
Nope, #token works only with #defines like in:
#define stringify(x) #x
#define str_exp(x) stringify(x)		/* this extra level IS necessary */
static char *junk = str_exp(JUNK) "ways ....";

I once encountered a Compiler (Aztec C on Amiga) which would translate
your code, but it isn't ANSI (gcc for example barfs at that: parse error 
before `#').


> The construct #JUNK generates the string "50", which is
> concatenated with its neighbour.

-- 
Walter Misar                                | It is impossible to enjoy
misar@rbg.informatik.th-darmstadt.de        | idling thoroughly unless
                                            | one has plenty of work to do.
From: darcy@druid.uucp (D'Arcy J.M. Cain)
Newsgroups: comp.lang.c
Subject: Re: should main be prototyped?
Date: 22 Jan 93 12:37:50 GMT
Organization: D'Arcy Cain Consulting

steve@taumet.com (Steve Clamage) writes:
>darcy@druid.uucp (D'Arcy J.M. Cain) writes:
>>  int main(void); /* prototype main   -   1/2 :-) */
>>  int main(void)
>>  {
>The prototype declaration for main() in your example has no effect
>whatever.  If you place a prototype declaration at the top of a file
>or in a header, it allows a function to call the prototyped function
>from a point where the function definition is not visible.  Placing
>the prototype declaration on the line immediately before the function
>definition is pointless, IMHO, and not a justifiable programming practice.

You're right.  The only reason I do it is to keep Gnu quiet when I use
the -Wmissing-prototypes.  It would be nice if Gnu recognized that main()
was a special case and didn't issue the warning for that case or better
yet checked that the definition of main followed one of the two possible
forms form main.  Preventing one warning in an otherwise warning free
compile is the justification in my case.

-- 
D'Arcy J.M. Cain (darcy@druid.com)  |
D'Arcy Cain Consulting              |   There's no government
Toronto, Ontario, Canada            |   like no government!
+1 416 424 2871          DoD#0082   |
From: folsom@bigmax.UUCP (Al Folsom)
Newsgroups: comp.lang.c
Subject: The Joy of C
Keywords: Text Books
Date: 22 Jan 93 13:41:19 GMT
Organization: Fischer & Porter Co., Warminster, PA.


Does anyone have any experience with the book "The Joy of C"
by Lawrence Miller and Alexander Quilici?  It is being touted
as a textbook to be used in our intro to C course.  On a 
_cursory_ examination I have the following observations:

Negatives:
   Somewhat disjointed (Arrays are covered in three distinct
	   areas.
   Emphasis seems odd, multi-dimensional arrays rate an entire
	   chapter, but pointers aren't discussed at all until
	   chapter 13, n the "advanced data types" section.
	   Similarly, file I/O is lumped into a "real world" section,
	   along with data types like l;ists and trees.  I don't expect
	   to teach binary trees in a C intro course, but I darn well
	   *better* teach file I/O!
   The section on the standard library is a bit more chatty
	   than I would like.  I would prefer a more "manual page"
	   type format, to aid in referencing the information.
   It makes more assumptions abou the language and library than
	   warranted.  Section on the time(), function, for example,
	   says "time returns the time in seconds since some distant
	   past."  I can find no reference in the ANSI standard that
	   says that, despite the fact that many implementations do.
Positives:
   Lots of examples.
   Disk is included with example software, make scripts, and
	   other tools
   Sections on efficiency and portability, often missing from
	   textbooks.
   A short section to introduce C++.
   Key points are highlighted in boxes, so they don't get lost
       in all the (long) discussion and examples.
   Problem areas _seem_ to be covered thoroughly.

If anyone has any experience with this text, I'd appreciate your
thoughts.  This includes both formal classroom experience, or use
by youself to study the language.  In particular, it's tough to know 
how frequent errors or mis-statements are, without using it once.  
Also, I teach one three hour class a week for 16 weeks; hints as to 
how easy it is to structure a syllabus around the book would be 
appreciated.

Thanks for your help.

Al F.

+-------------------------------------------------------------------+
| Al Folsom                 | Object Oriented Programming?  We've   |
| Fischer & Porter Co.      | been doing that for years...          |
| ...uunet!bigmax!folsom    |                                       |
| also folsom@decus.org     | When the customer objects to the way  |
| KY3T@WA3TSW (Ham)         | it works, we go program some more!    |
+-------------------------------------------------------------------+
From: staff@rabbit.augs.se (Staffan Friberg)
Newsgroups: comp.lang.c
Subject: Re: should main be prototyped?
Distribution: world
X-NewsSoftware: GRn 1.16f (10.17.92) by Mike Schwartz & Michael B. Smith
Date: 20 Jan 93 22:16:20 CET
Organization: Amiga User Group Sweden

In article <1993Jan17.000840.20657@csservices.Princeton.EDU> blume@kastle.Princeton.EDU (Matthias Blume) writes:

> int mymain (int argc, char **argv)
                             ^^^^^^

Sorry to burst in like this but isn't this wrong? I was told that you should
use *argv[] instead of **argv. They are clearly not the same thing.

If this is a FAQ I'm sorry but I have only been here a few days.

BTW. is there a FAQ-sheet somewhere and if that is the case, where can I find
it?

Thanks for your time.

--
  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  + Staffan Friberg                   +  EMail:                         +
  + Undergraduate student  Chemistry  +                                 +
  + Linkoping University              +  InterNet: staff@rabbit.augs.se +
  + Sweden                            +  FidoNet:  2:204/404.2          +
  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  Life, loathe it or ignore it, you can't like it.   (Marvin)
From: scjones@thor.sdrc.com (Larry Jones)
Newsgroups: comp.lang.c
Subject: Re: c and modula2
Date: 26 Jan 93 16:33:36 GMT

In article <1993Jan25.184916.23553@mcshub.dcss.mcmaster.ca>, cs4gp6au@maccs.mcmaster.ca (Lockie      RJ) writes:
> Here's some Modula-2 code:
> TYPE ex = ARRAY[0..10] OF CHAR;
> VAR test : ARRAY[0..10] OF ex;
>     p : POINTER TO ex;
> BEGIN
>   p = ADR(test[0]);
>   INC( p );
>   (* p now points to test[0][1] *)

A better translation of this to C than what you gave would be:

	typedef char ex[11];	/* [0..10] is 11 elements */
	ex test[11];
	ex *p;
	p = &test[0];   /* or p = test */
	p ++;
	/* p now points to test[1] according to K&R2 pg. 98 */

> So, if the above code is correct, the question I have is why does
> incrementing a pointer in C point to the next element in the array?
> while in Modula-2 it doesn't (the pointer needs to be incremented
> by the size of the array element).

Because that's the definition of pointer arithmetic in C.  If p points
to an 11 element array and you increment it, doesn't it make sense that
it then points to the next 11 element array?

> How does C do that? Is it the compiler?

Yes, the compiler does whatever is necessary to meet the definition of
pointer arithmetic.  For an implementation on a traditional linear
address space machine, this corresponds to multiplying the increment
by the size of what the pointer points to and then adding the result
to the address the pointer is currently pointing to.
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
larry.jones@sdrc.com
It's going to be a long year. -- Calvin
Newsgroups: comp.lang.c
From: kaleb@jpl-devvax.jpl.nasa.gov (Kaleb Keithley)
Subject: Re: The Coming Crisis
Organization: Jet Propulsion Laboratory (NASA)
Date: Thu, 28 Jan 1993 17:02:34 GMT

In article <1993Jan28.134302.7006@stsci.edu> kimball@stsci.edu (Timothy Kimball) writes:
>George Mitchell (george@tessi.com) wrote:
>: 
>: In less than 8007 years, asctime () will need a 28-character buffer,
>: instead of a 27-character one, in which to return its result.
>: -- George Mitchell (george@tessi.com)
>
>My God!  Quick! Somebody convene a committee!  (X3J10000, maybe?)
>
>Bartender!  Smileys all around!
>

That's not nearly as bad as the fact that in less than 70 years gettimeofday()
will overflow the tv_sec member.  Gee, I hope I'm still alive to see it.

What, this is comp.lang.c?  I thought it was alt.millenium.boom.boom.boom.
Sorry. :-) :-)

-- 

Kaleb Keithley                               kaleb@jpl-devvax.jpl.nasa.gov

Newsgroups: comp.lang.c
From: "peter curran" <peter.curran@canrem.com>
Subject: Neophyte C programmer needs HELP!
Reply-To: "peter curran" <peter.curran@canrem.com>
Organization: Canada Remote Systems
Distribution: comp
Date: 26 Jan 93 07:07:51 EST


In <1993Jan22.040237.9860@organpipe.uug.arizona.edu>,
                        dave@cs.arizona.edu (Dave Schaumann) writes...

[after describing a non-dynamic-programming solution to a problem]

DS>BTW, for those wondering, dynamic programming is a method which
DS>an algorithm that would otherwise have combinatorial time complexity
DS>uses (typically a 2-dimensional) array to hold intermediate results.
DS>Exploiting the fact that the combinatorial nature of the algorithm
DS>results from computing the same functions over and over again, this
DS>"saving of intermediate values" results in a polynomial-time algorithm.

DS>Those further interested by my (admittedly weak) description of
DS>dynamic programming are advised to locate a good algorithms book.

To forestall confusion, it should be made clear that "dynamic
programming" has nothing to do with "computer programming" (except
that computers are usually used to implement solutions).  The
idea was invented by Richard Bellman, sometime around the early
50's, I believe.  It is considered a field of Operations Research.
It can produce feasible solutions to many otherwise-intractible
optimization problems.

Two of the classic references are:

Applied Dynamic Programming, by Richard E. Bellman and Stuart E.
Dreyfus, Princeton University Press, 1962.

Introduction to Dynamic Programming, George L. Nemhauser,
John Wiley and Sons, 1966.

Peter Curran                          FidoNet: 1:229/15
Usenet: peter.curran@canrem.com       RIME:    CRS (#118)
---
  DeLuxe 1.25 #12339  
--
Canada Remote Systems  - Toronto, Ontario
World's Largest PCBOARD System - 416-629-7000/629-7044
From: kdq@quest.UUCP (Kevin D. Quitt)
Newsgroups: comp.lang.c
Subject: Re: =======Problem with mmap command on DECStation========
Date: Wed, 27 Jan 93 18:08:35 PST
Reply-To: srhqla!quest!kdq
Organization: Job quest  (805) 251-8210,  So Cal: (800) 400-8210

roy@spectrum.cs.unsw.oz.au (Prabal Kumar Roy) writes:
...
> However, at the statement    *intptr = 1; I am getting the following error.
> pid 10810 (a.out) was killed on kernel access, at pc 0x400284.  Bus error (co
> dumped).  
...
>   result = (caddr_t) mmap(0, 1000, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
>   intptr = (int *) result;
>   *intptr = 1;

    Uh, have you bothered to check 'result' to see if the return from
mmap is a null pointer?  I assume that's what you'd get if the call
fails.  I highly recommend such bulletproofing.


 _
Kevin D. Quitt      96.37% of all statistics are made up.     srhqla!quest!kdq
Newsgroups: comp.lang.c
From: stevekim@panix.com (Steve Kim)
Subject: C++ books
Organization: PANIX Public Access Unix, NYC
Date: Sun, 24 Jan 1993 21:54:59 GMT

I am not much of a programmer.  I want to learn C++.  I have some experience
in assembler and basic (pathetic huh?).  Anyway, I am looking for a good
book that I can use.  Also is C++ limited to dos or can I use programs 
written in C in UNIX.
From: amand@granit.unice.fr (Amand Pascal)
Newsgroups: comp.lang.c
Subject: Tool for cross references in C ???
Date: 22 Jan 1993 10:46:26 GMT
Organization: University of Nice - Sophia Antipolis
Distribution: world
NNTP-Posting-Host: granit.unice.fr
Keywords: cross reference

	Hi,

	Does anybody know a tool to get cross references in
	C modules, i.e.:

	- where is used a variable
	- who calls a function ...

	Thanks.

-------------------------------------------------------------------------------
Pascal Amand                                Email: amand@essi.cerisi.fr
DEA Informatique                        
I3S - Sophia Antipolis - France
-------------------------------------------------------------------------------


Xref: sparky comp.lang.c:20258 comp.lang.fortran:5194
From: jrbd@craycos.com (James Davies)
Newsgroups: comp.lang.c,comp.lang.fortran
Subject: Re: calling a Fortran subroutine from a C program
Date: 26 Jan 93 17:42:44 GMT
Distribution: na
Organization: Cray Computer Corporation

In article <1993Jan26.160622.24483@sol.ctr.columbia.edu> shenkin@still3.chem.columbia.edu (Peter Shenkin) writes:
>In article <ig25.728061129@fg30> ig25@fg30.rz.uni-karlsruhe.de (Thomas Koenig) writes:
>>An implementation might very well choose to start every character
>>variable on a word boundary, for speed reasons.
>>
>>      CHARACTER*1 STRING(100)
>>
>>would then appear to C to be an array of ints, instead of chars.
>
>I think Cray in fact does this, while placing CHARACTER*1 scalars
>on byte boundaries.

While it's true that Cray compilers will align local variables on word 
boundaries, it isn't possible to do that for character arrays or character 
variables in COMMON.  This is due to the storage layout rules imposed by the
Fortran 77 standard, which requires that
	CHARACTER*1 A,B,C
	COMMON/A/ A,B,C
in one routine, and
	CHARACTER*3 A
	COMMON/A/ A
in another must refer to the same three character locations.  Also,
it's legal to map the storage in ways like this (an example from the
standard):
	CHARACTER A*4, B*4, C(2)*3
	EQUIVALENCE (A,C(1)), (B,C(2))
01      02      03      04      05      06      07
------------A--------------
                       -------------B-------------
--------C(1)-------    -------C(2)--------
Newsgroups: comp.lang.c
From: brown@NCoast.ORG (Stan Brown)
Subject: Re: Accessing DOS Environment w/MSC
Organization: Oak Road Systems, Cleveland Ohio USA
Date: Wed, 27 Jan 1993 13:11:40 GMT

I'm posting my response, in addition to emailing, because past
experience shows that the last paragraph is of interest to many more
readers than the one who posted the original query.

In article <C1G81B.KII@news.udel.edu> brad@ravel.udel.edu (Brad Cain) writes:
>I need to access the dos enviroment in a program that i'm writing.
>I am using microsoft C 5.1, and am aware of the putenv and getenv
>commands... however, i need to access the 'real' dos enviroment,

This is not about the C language, but about MS-DOS programming.
Fortunately, there's a comp.os.msdos.programmer newsgroup for just such
topics as this.

But don't post your question there, because it's answered in the
comp.os.msdos.programmer FAQ; see Q704.

If you can't find the FAQ, send me email >>> with a valid reply-to
address <<< and I'll bounce back a canned message that explains how to
retrieve many FAQ lists.

-- 
Stan Brown, Oak Road Systems                    brown@Ncoast.ORG
Cleveland, Ohio, USA
"Compared to my life, the last man on a chain gang is thoroughly
enjoying himself."                   __Holiday__ by Philip Barry
Newsgroups: comp.lang.c
From: steve@taumet.com (Steve Clamage)
Subject: Re: Is this a Legal Way to Access a Specific Address?
Keywords: DSP, C, ANSI, Fixed RAM
Organization: TauMetric Corporation
Date: Sat, 23 Jan 1993 19:41:16 GMT

rs@cmie.ernet.in (Rajappa Iyer) writes:

>scotty@verdix.com (Scott R. Chilcote) writes:

>>We're programming a device that has a RAM cache at address 809800H.
>>Is it legal to address this memory in C as follows?
>>#define ON_CHIP 0x809800
>>int main(void)
>>{
>>   float *oc_ptr = (float *) ON_CHIP;

>It is definitely legal C.

It is syntactically legal C, but the results of using the code are
undefined by any standard.  That is to say, you can't predict
a priori whether the code will do what you want.

Compilers typically have ways of allowing absolute machine addresses to
be assigned to pointers, but the method depends on the machine and the
compiler.  You have to check the compiler manual.

If parts of the code are machine-specific, as this clearly is, it is
usually a good idea to isolate such code in separate modules.  That
code is then tailored for the machine and compiler.  The remainder
of the code (assumed to be portable) can be left alone when you change
compilers or machines.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
From: roy%cybrspc@cs.umn.edu (roy)
Newsgroups: comp.lang.c
Subject: Re: How do you read binary data piped into stdin?
Date: Tue, 26 Jan 93 06:28:40 CST
Organization: Villa CyberSpace, Minneapolis, MN
X-Newsreader: rusnews v0.97

pdh@netcom.com (Phil Howard ) writes:

> Unfortunately, standard C lacks a facility to change the mode of an open
> file.  This would be what you need, and I have had situations where I need
> this as well.

What about setmode()?  My FM says the call is available on Unix systems.
Is the FM lying to me?  (I s'pose it wouldn't be the first time)
--
Roy M. Silvernail --    [my machine ] "Sometimes, you're the windshield....
roy%cybrspc@cs.umn.edu  [my opinions]            sometimes, you're the bug!"
cybrspc!roy@cs.umn.edu  [my $0.0275 ]                      --Mark Knopfler
Newsgroups: comp.lang.c
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Re: Use of ANSI qsort
Keywords: qsort
Organization: Computer Science, University of Melbourne, Australia
Date: Sun, 24 Jan 1993 03:57:46 GMT

scst81@csc.liv.ac.uk (Mr. I. Rowland) writes:

>I am using the ANSI function qsort to sort an array of structs.
[...]
>qsort((char *) clast_record,
>	    (unsigned) num_records, 
>		sizeof(struct clast_item),lithology_compare);
>}

qsort is prototyped as
	void qsort(void *, size_t, size_t,
		   int (*) (const void *, const void *));

There is no need to cast 'clast_record' to (char *).
'num_records' should probably be cast to (size_t) rather than (unsigned),
if it does indeed need to be case, but it is perhaps better to declare
'num_records' to be of type size_t in the first place.

>The lithology_compare function is as follows :
>
>int lithology_compare (struct clast_item *a, struct clast_item *b) {
>	return strcmp(a->lithology,b->lithology);
>}

The prototype for lithology_compare() must be exactly the same as given in
the prototype for the fourth argument of qsort(). i.e.

	int lithology_compare (const void *x, const void *y);

In the function you then need to cast the (const void *) pointers to the
correct type before using them. For example,

	int lithology_compare (const void *x, const void *y) {
	    struct clast_item *a = (struct clast_item *) x;
	    struct clast_item *b = (struct clast_item *) y;
	    return strcmp(a->lithology,b->lithology);
	}

-- 
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,comp.std.c
From: rs@cmie.ernet.in (Rajappa Iyer)
Subject: Re: Preprocessor question
Keywords: Preprocessor, string
Organization: Centre for Monitoring Indian Economy, Bombay
Date: Wed, 27 Jan 1993 07:28:14 GMT

karim@bnrmtl.bnr.ca (Karim Younes) writes:

>I am trying to have a #defined variable recognized by the
>preprocessor inside a string. In other words, I want to
>do something like this:

>#define JUNK 50
>static char *junk = "JUNK ways to leave your lover."

The only ANSI way I can think of doing it is (yecch!):

#define JUNK "50"
static char *junk = JUNK " ways to leave your lover."

Interestingly, I tried the following with gcc 2.2.2:

#define JUNK	50
#define STR(x)	#x

char *junk = STR(JUNK) " ways to leave your lover."

junk expands to "JUNK ways to leave your lover." Which kind of
makes me question the utility of the `#' preprocessor operator.
K&R 2 says that "... replacement token sequence is preceded by #,
string quotes (") are placed around the corresponding parameter
and then both the # and the parameter identifier are replaced by
the quoted argument."

In other words, in the above example `x' is replaced by `JUNK'
and quoted---`JUNK' is not expanded. Is this indeed the correct
behavior? If it is, I really think it severely restricts the
utility of the `#' operator. Any comments, anyone?
-- 
Rajappa Iyer			rs@cmie.ernet.in (Preferred)
				riyer@shakti.ncst.ernet.in
From: james@cs.mcgill.ca (Luc MIKISZKO)
Newsgroups: comp.lang.c
Subject: C and assembly linking problems ! HELP!!
Date: 23 Jan 93 17:53:41 GMT
Organization: SOCS - Mcgill University, Montreal, Canada



	Hi there,

		I would be sooooo glad if someone could
		please explain me what I am doing wrong:

		- I am trying to link assembly language
		routines with C

		I haven't written them myself but I know
		that ll the proper declarations in the respective
		files are correct.

		Here's what I did: let's say I have  files: 
		L1.C
		L2.ASM 

		I do exactly this:   tcc l1.c
				     tasm l2

		Then, no problem, not a single warning or error;

		BUT when I link them : tlink l1 l2, exefile

		Then I get messages saying that functions such
		as "GETCH_", "PRINTF_" are not defined ?!?!?!?

		and it seems that all the assembly routines have been
		"understood".

						Please help me...
From: jhurwitz@access.digex.com (j. hurwitz)
Newsgroups: comp.lang.c
Subject: Need help with calls to DOS from Turbo C++
Date: 27 Jan 1993 20:06:58 -0500
Organization: Express Access Online Communications, Greenbelt, MD USA
Distribution: all
NNTP-Posting-Host: access.digex.com
Keywords: exec dos

When I was programming in Turbo Pascal there is a command 'Exec' that lets
you put a DOS shell in your apps or make calls out to DOS from inside of
your program. My question is, is there a way to do the same in Turbo C++?.
I have looked through the manual and a few Turbo books, but can't seem to 
find anything related to this subject. Maybe it's called something else.
If someone could point me in the right direction, I would be forever greatful.
Sorry if I am posting in the wrong newsgroup. Please direct me to the correct 
one if so. Thanx a bunch in advance.

	
          __/ /          .                     +             .
        _/__/_/\                                
      _/____/ \/  J. Hurwitz                                          ,
  .  /     / \/|          .          *                   
    /     /  /|/  The MIDI master             .                  o
   /_____/  / |                                         
  //____/\\/ /  Roaming Cyberspace          "Space is the place"        
  /  o  \ ||/    .                     
 | o   o |//                                .          -Sun Ra      +
  \o   o//     jhurwitz@access.digex.com          
   --^--   .                                            *        
+                         '               +
From: 00clcoffing@leo.bsuvc.bsu.edu
Newsgroups: comp.lang.c
Subject: VGA scrolling
Date: 27 Jan 93 16:30:37 GMT
Organization: Ball State University, Muncie, In - Univ. Computing Svc's

I am writing an arcade game in Turbo C, and want to know how to smootly scroll
VGA graphics horizontally.  (i.e., I need to pan the screen across several
screen widths of terrain.)

anyone out there want to share their vast stores of knowledge?

reply here or email 00clcoffing@bsuvc.bsu.edu

thanks in advance
Newsgroups: comp.lang.c