HDTenEightyP/NetNews huggingface dataset:
From: caliaro@avalon.physik.unizh.ch (Aurelio Caliaro)
Subject: stderr: Question
Summary: redirect fprintf(stderr, ...)
Keywords: fprintf stderr
Organization: University of Zurich, Department of Computer Science
X-Newsreader: Tin 1.1 PL4
Date: Mon, 21 Dec 1992 13:46:08 GMT

Hi all...
I would like to redirect all output made by "fprintf(stderr, ...)" to a
procedure. Is that possible without changing the source everytime that
stderr comes? Maybe a #define?


               Thank you!


                     Aurelio Caliaro


Answers please into this group, or to caliaro@avalon.physik.unizh.ch.
From: ta-psc10@cunixa.cc.columbia.edu (Po Shan Cheah)
Newsgroups: comp.lang.c
Subject: Re: Scanf field width macro?
Date: 28 Dec 92 22:33:05 GMT
Reply-To: ta-psc10@cunixa.cc.columbia.edu (Po Shan Cheah)
Followup-To: poster
Organization: Columbia University

In article <1992Dec28.213129.8983@nosc.mil> mitch@nosc.mil (Ray Mitchell) writes:
>
>Consider the statements
>
>   printf("%*s", field_width, char_buffer);
>    scanf("%5s", char_buffer);
>
>I would like to avoid embedding the magic field width constant in the
>scanf.  I don't need it to be a variable field width like in printf
>but only need it to be in terms of some constant width macro I've
>previously defined.  I've tried various things using stringization,
>token pasting, etc. to no avail.  A solution which does not depend
>on some non-standard preprocessor/compiler behavior is required.

Try this:

#define FIELD_WIDTH 5

#define tostr2(x) #x
#define tostr(x) tostr2(x)

scanf("%" tostr(FIELD_WIDTH) "s", char_buffer);

Hope this works.

Po Shan Cheah
ta-psc10@columbia.edu
pc30@columbia.edu
pcheah@nyx.cs.du.edu
From: qding@uoft02.utoledo.edu
Newsgroups: comp.lang.c
Subject: Help: Save data in Windows C program
Date: 30 Dec 92 00:05:57 EST
Organization: University of Toledo, Computer Services

Hi, dear netters.

I am a new Windows programmer. I am traslating a DOS program to Windows.
One problem I got is that I can not write something to the disk by using
the original program. The program is:

        FILE *fp;
        fp=fopen("test.dat", "w");
        fprintf(fp, "%s", "some data");
        fclose(fp);

Could somebody there help me to translate the statements into Windows 
C program, please?

Thanks in advance.

David
From: keith@torme.sharebase.com (Keith Chambless)
Newsgroups: comp.lang.c
Subject: Re: A different C puzzle
Date: 23 Dec 92 18:53:48 GMT
Reply-To: keith@torme.sharebase.com (Keith Chambless)
Organization: NCR/ShareBase Corporation

In article <1992Dec23.092712.2408@sq.sq.com> msb@sq.sq.com (Mark Brader) writes:
>> > Write a [C] program that uses every valid character exactly once.
>> I should think it would be rather difficult to use only one " ...

Best I could come up with is:

#

main()
{
	double *ABCDEFGHIJKLMNOPQRSTUVWXYZ[],
		   c_fghjkpqrstvwxyz = -!9 + 8.0 / 7 > 6 < 5 % 4 ? 3 : 2 & 1;
}


missing are ' " \
From: hbf@durin.uio.no (Hallvard B Furuseth)
Newsgroups: comp.lang.c
Subject: Re: assert
Date: 22 Dec 92 14:25:01 GMT
	<9212211543.PN29748@LL.MIT.EDU>
Organization: University of Oslo, Norway


In article <9212211543.PN29748@LL.MIT.EDU> lebrun@ll.mit.edu (Steven F. LeBrun) writes:

> I took a look at the ANSI C document (X3.159-1989) and could not find a
> section that states that standard header files cannot include other
> standard header files.

I found it: 4.1.2.1 lists reserved identifiers, and says *no other
identifiers are reserved*.  (Non-underscore) macros are reserved if any
of their associated headers are included.  So assert.h may not define
stderr because it is not explicitly allowed to do so.
--

Hallvard
Newsgroups: comp.lang.c,comp.lang.c++,comp.misc
From: swillden@news.ccutah.edu (Shawn Willden)
Subject: Re: What is Object Oriented Programming? Is C doomed?
Organization: University of Utah Computer Center
X-Newsreader: Tin 1.1 PL3
Date: Wed, 30 Dec 92 20:01:11 GMT

nagle@netcom.com (John Nagle) writes:
: swillden@news.ccutah.edu (Shawn Willden) writes:
: >	Is this scheme similar to the one you had in mind?  If yours
: >is better, please share it (or provide references, I suppose I ought
: >to check Knuth to see if he has anything like this).
: >In any case, I like the idea well enough that I think I'm going to
: >start using it.
: 
:        Look into B-trees for this sort of thing.  But don't look in
: Knuth's "Art of Computer Programming" for them; they postdate that classic
: work.

Not true.  B-trees are discussed by Knuth in the "Art of Computer
Programming".  And B-trees are ordered, something that is not required
and probably not wanted in the application I was discussing.  

: John Nagle

--
Shawn Willden
swillden@icarus.weber.edu
From: bazyar@teal.csn.org (Jawaid Bazyar)
Newsgroups: comp.lang.c
Subject: Simple C Interpreters
Date: 3 Jan 93 18:30:39 GMT
Organization: Colorado SuperNet, Inc.

I'm looking for a simple C-like interpreted language for use in a
telecommunications program.  I've heard that two issues of Dr. Dobb's
Journal some time ago had articles describing some, but I don't
have Dr. Dobb's and am hoping that someone already has them in use
on the internet.

Are there any other C-like interpreters I should be aware of?

Thanks in advance..

-- 
 Jawaid Bazyar              |   Ask me about the GNO Multitasking Environment
 Procyon, Inc.              |   for the Apple IIgs!   
 bazyar@cs.uiuc.edu         |   P.O Box 620334
 --Apple II Forever!--      |   Littleton, CO 80162-0334   (303) 933-4649
Newsgroups: comp.lang.c
From: gilmour@binah.cc.brandeis.edu (Jeffrey R. Gilmour)
Subject: Reading Directories+
Reply-To: gilmour@binah.cc.brandeis.edu
Organization: Brandeis University
Date: Sat, 2 Jan 1993 00:11:40 GMT

As par the FAQ, I looked into FINDFIRST & OPENDIR when I wanted to figure
out how to play with the directory and list files.  But I haven't been able
to find an easy way to get the disk name and also the bytes free.  Advice
anyone or could you share the particular function you use for this?  Thanks.

___________________________________ 
|__/~~~~~\__/~~~~\__/~~~~\__/~~~~\_|/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
|____/~\____/~\_____/~\_____/~\____|\                                          /
|____/~\____/~~~\___/~~~\___/~~~\__|/   T h i s   S p a c e   f o r   R e n t  \
|____/~\____/~\_____/~\_____/~\____|\                                          /
|__/~~~\____/~~~~\__/~\_____/~\____|/       GILMOUR@BINAH.CC.BRANDEIS.EDU      \
|__________________________________|\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Newsgroups: comp.lang.c
Subject: Sparse arrays..ARGH!
From: powalisz@nrlvx1.nrl.navy.mil
Date: 22 Dec 92 12:05:53 -0400
Organization: NRL SPACE SYSTEMS DIVISION

I have a question about Sparse Arrays:

If the array elements are declared as structs:

struct sparse{
              int col;
              int row;
              int val;
              struct sparse *nextcol;
              struct sparse *nextrow;
              } 

how can I return 'val' recursively and return 0 if there is no element at that
row and column. The function prototype desired is:

retreive(struct sparse *a, int *col, int * row)

Yes, this was part of a question I had on afinal exam, and I was wondering what 
the solution was, since I know I didn't have the correct one.

Please respond via this newsgroup to give other users the knowledge, too.

Ron Powalisz

Newsgroups: comp.lang.c
From: gglass07@ursa.calvin.edu (Gideon Glass)
Subject: Re: Newbie Wants Advice on C-Programming
Organization: Calvin College
Date: Sun, 3 Jan 1993 03:09:58 GMT

jimlynch@netcom.com (Jim Lynch) writes:
>In article <1992Dec24.172333.7339@grebyn.com> malak@grebyn.com (Michael Malak) writes:

[Much deleted]

>>You should always start out with the official books:
>>
>>For C, it is _The_C_Programming_Langauge_ 2nd ed. by Kernighan & Ritchie
>>For C++, it is _The_C++_Programming_Language 2nd ed. by Stroustrup

>No no no no no no no no no no no no. These books are _unreadible_ to a beginner.
>However, they can be quite valuable as a reference (whenever you get around to
>learning how to read them...)

It's been my experience that you have things backwards.  I taught myself
C using K&R2 in about a month.  The only experience I had before that was
1 semester of Modula-2 and a little BASIC.  I would recommend K&R2 to others
who have programming experience and who want to learn C.  As they say,
your mileage may vary.  As for reference, I've only used it occasionally.

>>For each language, you may optionally buy a more tutorial or descriptive
>>book.  

>If you expect to learn C/C++ in any resemblence of a pleasant experience,
>this is *NOT* optional.

I think this is a rather drastic overgeneralization.

>>The books listed above are more reference books than tutorials.
>>Although they do start with the basis, and then build on them, they do
>>so in a math book kind of way.  Just go to a computer book store and
>>thumb through some of the books and buy the one(s) that appear to teach
>>the way you like to learn.  

>This is arguably the best comment you have made. I agree completely.

I went to a bookstore and I ended up with C PROGRAMMING LANGUAGE.

>world of the internet. Verification takes a long time. Understanding those
>practically-unreadible-but otherwise-great reference texts also takes a long
>time. Learning to program in C takes a long time too but not _as_ long.

I thought C was a lot easier to learn than Modula-2.


Just my opinions, etc.

Gideon Glass

--
Gideon Glass            <||||||>          gglass07@calvin.edu

/home/g/0146607/.signature: No such file or directory
From: Shawn.MacIntyre@ttlg.UUCP (Shawn MacIntyre)
Newsgroups: comp.lang.c
Subject: Workframe/2 Problems
Date: 22 Dec 92 03:40:26 GMT

* Original Area: IBM.OS2PRO
* Original To  : All (40:6494/1022)

* Original To  : All! (40:6494/1022)

        When chosing a compiler of OS/2 v2.0 i finally made the decsion to get the IBM C Developers Workset/2 v1.0...now every thing works just fine except for the workframe/2...after hte first two times of runing it, it worked fine...then on the third, and the rest of the time, it opens like it normaly does then closes itself all but the actions log and project managment windows...any idea on what's going on? i'v tried every thing that comes to mind including reinstalling the whole workset...help me pleas






e...and does any now if there is a help-line for workset/2?
 
-thanks

-shawn<very frustated>macintyre

p.s. now every thing runs so slowly?!? an i have a 386dx-40 with 8 meg if this helps

 * Origin: Mach2 Vulcan OS/2 Systems 1-403-489-4250 (42:100/20)
Newsgroups: comp.lang.c
From: woods@robohack.UUCP (Greg A. Woods)
Subject: Re: sccs eats good code -
Organization: Elegant Communications Inc.
Date: Sat, 26 Dec 92 06:27:43 GMT

In article <1992Dec22.090329.11162@dcs.warwick.ac.uk> rince@dcs.warwick.ac.uk (James Bonfield) writes:
> I'd certainly agree with abolishing sccs. I've never really been 'into' source
> management systems, but when I have had to use them I've found RCS invariably
> better.

It's too bad you think that way.  SCCS, as a change control management
tool for files, is very powerful, easy to use, and a standard part of
every (real) UNIX system.

RCS is different.  Not necessarily much better.  It all depends upon
your requirements for such a tool.

If you want a really powerful tool, layer CVS-1.3 on top of RCS-5.6!

> Do you notice anything blindingly wrong with this? Sccs has the intelligent
> idea of giving control characters special meaning within the history file. And
> it doesn't bother to escape any of the ones you happen to have typed in. This,
> naturally, means that if you enter a control char into your source then upon
> the next 'get' or 'edit' sccs will kindly remove the only existing copy you've
> got and *then* complain that it doesn't understand the history file.
> 
> For this reason using sccs actually slowed down and hampered my development by
> a huge factor. Surely this isn't the scheme of such things? On the contrary
> the next time I was asked to make use of such a system I put RCS to the test

Whew!  What kind of code were you writing anyway?!?!?  I've only twice
encountered a conflict with SCCS's keyword expansion control codes --
once in the same situation as the original poster noted, and once when
I wished to include an example SCCS keyword string in a source module.

That's twice out of thousands of modules.  I know of large projects
with millions of lines of code, in tens of thousands of modules, all
managed with the use of SCCS, and no conflicts that couldn't be easily
dealt with.

RCS will do the same thing, though it has far fewer combinations of
strings with which it might find conflict.
-- 
						Greg A. Woods

woods@robohack.UUCP, woods@Elegant.COM  VE3TCP	UniForum Canada & ECI
+1 416 443-1734 [home] +1 416 362-XRSA [work]	Toronto, Ontario; CANADA
Newsgroups: comp.lang.c
From: darcy@druid.uucp (D'Arcy J.M. Cain)
Subject: Re: return value of fseek()
Date: Mon, 28 Dec 1992 21:33:59 GMT
Organization: D'Arcy Cain Consulting

hendrik@zeusa.UUCP (Hendrik Vermooten) writes:
>The ANSI C standard says that fseek() returns a 0 for success. I read
>somewhere that System V returns non-zero for success!

That "somewhere" obviously wasn't the man page.

-- 
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: mark@ocsmd.ocs.com (Mark Wilson)
Subject: show PCX
Organization: Online Computer Systems, Inc.
X-Newsreader: Tin 1.1 PL5
Date: Tue, 22 Dec 1992 15:00:59 GMT

Does anyone know of a good source of source code for displaying graphics
from within a C program?  Public-domain or freeware, natch...
The types of graphics I'm most interested in are
PCX (and GIF if possible)... I have Rimmer's book (two different
editions) on "Bit-Mapped Graphics" but the programs given don't
work (either at all or, in one case, well).  I'm talking about
PC machines, using MS C7.0.  This seems appropriate for this newsgroup,
but please hold any flames if not, just lemme know where else to put
it.  Thanks!

(I'd especially like memory-stingy routines, but ANYTHING is OK!)

- Mark

--
-------------------------------------------------------------------------------
Mark Wilson, Online Computer Systems.  1-800-922-9204 or 1-301-601-2215
(Try email address mark@wilson.ocs.com....)
This file .disclaims everything signed with my .signature, I .mean it!
-------------------------------------------------------------------------------
Newsgroups: comp.lang.c
From: hollasch@kpc.com (Steve Hollasch)
Subject: Re: Problem with string processing.
Organization: Kubota Pacific Computer, Inc.
Distribution: usa
Date: Mon, 4 Jan 1993 02:27:37 GMT

matujos@elof.iit.edu (Joe Matusiewicz) writes:
| 
|    I need a function to append a character to the end of a string.
| I can't find an ANSI function to do so, so I tried to write my own.
| Here's what I have:
| 
|          void add_char_to_str(char ch, char *str)
|          {
|              char *tmp;
|              tmp = (char *) calloc (2*sizeof(char));
|              *tmp = ch;
|              *(tmp+1) = '\0';
|              strcat(str, tmp);
|              free (tmp);
|          }

    calloc() takes two parameters:  number of elements, and element size.
You should be using malloc here.  Also, you have a lot of overhead for such
a simple operation.  Here's how I'd do it.

        void add_char_to_str (
            register char  ch,     /* Character to Append */
            register char *str)    /* Old String */
        {
            while (*str) ++str;
            str[0] = ch;
            str[1] = 0;
        }

    This assumes that the space pointed to by 'str' has room for another
character.  A more forgiving routine would be:

        char *add_char_to_str (
            char  ch,     /* Character to Append */
            char *str)    /* Old String */
        {
            register char *ptr;         /* New String */

            if (!(ptr = malloc (strlen(str) + 2))) return 0;

            while (*ptr++ = *str++);    /* Note assign op and null body. */
            ptr[-1] = ch;
            ptr[ 0] = 0;

            return ptr;
        }

______________________________________________________________________________
Steve Hollasch                                   Kubota Pacific Computer, Inc.
hollasch@kpc.com                                 Santa Clara, California
From: wjb@cscsun2.larc.nasa.gov (William J. Bene)
Newsgroups: comp.lang.c
Subject: A good book on C ?
Date: 29 Dec 1992 18:41:29 GMT
Organization: NASA Langley Research Center, Hampton, VA  USA
Reply-To: wjb@cscsun2.larc.nasa.gov (William J. Bene)
NNTP-Posting-Host: cscpk.larc.nasa.gov

Other than K&R, are there any other C reference manuals that anyone cares to 
recommend?


Will
=======================================
William J. Bene
Computer Sciences Corporation
wjb@cscsun2.larc.nasa.gov
From: jkowalsk@spam.ua.oz.au (Jacek Kowalski)
Newsgroups: comp.lang.c
Subject: Looking for C/C++ functions for optimization
Date: 18 Dec 92 05:03:52 GMT
Distribution: world
Organization: Statistics, Pure & Applied Mathematics, University of Adelaide

Hi,

are there any C/C++ functions, publicly available on Internet, for a
constarined and unconstrained nonlinear optimization (e.g. something
like appropriate Fortran NAG routines)?

Would you, please send the answer to my address jkowalsk@spam.edu.au, too.
I will be away for some time and I wouldn't like to miss it. Thanks.


Newsgroups: comp.lang.c
From: tonyl@vcd.hp.com (Tony Long)
Subject: Re: What is Object Oriented Programming? Is C doomed?
Date: Tue, 22 Dec 1992 18:58:46 GMT
Distribution: usa
Organization: Hewlett-Packard VCD
X-Newsreader: Tin 1.1 PL5

Richard M. Hartman (hartman@ulogic.UUCP) wrote:
: 
: OOP and C++ is NOT a "silver bullet", any more than "structured programming"
: was.  It is a new tool that gives us the potential for things that were
: more difficult before, but in and of itself does NOTHING.  That is the
: job of the software designer.  If it is done poorly, it is done poorly
: no matter what the language or paradigm.
: 
: 		-Richard Hartman
: 		hartman@ulogic.COM
: 
	I would just add that if OOP design *is* done poorly, the problems
of wading through virtual functions, overloaded operators/functions, 
inheritances, etc. to debug could be much worse of a nightmare than 
with classical languages!
	But, if mastered, I think the power and usefulness of abstract
structures will become self-evident, reflecting real-world structures
to a much greater degree than is evident in "traditional" languages.
	OOP is not for the ignorant, either! Using a tool or a machine
is not an escape into ineptness--more useful or powerful machines mean
greater potential for damage!

			---Tony Long---
From: rdorich@jade.tufts.edu (Rob)
Newsgroups: comp.lang.c
Subject: finding prime numebrs
Date: 22 Dec 92 00:21:59 GMT
Distribution: wold
Organization: Tufts University - Medford, MA


	Since some one else had something to prove in this newsgroup,
I'm going to post this (do we have/need a group gen.nums.proves?).
Ok, so here it goes:

	For any prime number, if we represent it in base 3, and then
get the addition of all the digits, I claim that:

	1.-	If the sum is even, then it is not a prime.

	2.- 	If it is odd:
			It is either prime.	
			or a multiple of another lower prime.

Ages ago (about 2 years) I made a little Pascal (ugh) program to do
this,  and it basically goes from 1 to n creating and checking if the
current number is prime, if it is, add it to a list.  Basically the
program has the following runtime:

		n + num_primes_to(n)

		which is a O(n) as n -> oo (infinity).

	How do you guys like this? proves? counterexamples? anything
would be most welcome.

Rob



--
-------------------------------------------------------------------------------
Roberto Dorich		 |           /~~  \ /  ~~/~~ /~~/  /~~  /|  /    /~~
			 |    SKI   /--    X    /   /__/  /--  / |/ |   /--
Electrical Engineering	 |         /__    / \  /   /\    /__  /     |  /__
rdorich@jade.tufts.edu	 |  Tufts University, College of Engineering.
-------------------------------------------------------------------------------
Newsgroups: comp.lang.c
From: kinetix@cwis.unomaha.edu (Andrew Wigodsky)
Subject: Help.. BC++ 3.1 and 19200 bps SerialCom
Organization: University of Nebraska at Omaha
Date: Wed, 23 Dec 1992 03:43:31 GMT

I am writing an emulator for IBM 3164 terminals, and I
have come across a problem with BC++'s serial communications..

THEY DONT INCLUDE SUPPORT ABOVE 9600 BPS?!?!?!?!

I must be missing something here... does anyone have any 
ideas?

Also, if you just _happen_ to have source to emulate a
3164 terminal, PLEASE send it!

Reply to:  kinetix@cwis.unomaha.edu

--
========================================================================

kinetix@cwis.unomaha.edu			Andrew S. Wigodsky
						University of NE, Omaha
Newsgroups: comp.lang.c
From: amead@s.psych.uiuc.edu (Alan Mead)
Subject: ALGORITHM to flexibly match strings needed
Organization: UIUC Department of Psychology
Date: Tue, 29 Dec 1992 04:56:04 GMT

Someone suggested that programmers here were, shall we say
exceptionally "with it"?  Anyway, although this has nothing to do with
C per se, I'd like to know about any algorithms for matching strings.
Specifically, I need to count typos in a sample string as compared to a
target string.  Obviously, I cannot just compare each char as an
initial additional stroke would cause numerous, erroneous errors.  Eg,
" Run Spot run." as a sample of "Run Spot run." is one error, not 13.

I've gotten as far as conceptualizing it as "sliding" the mis-matching
sub-string of the sample string left and right in increasing amounts
until a match is made, but I just cannot imagine how to code such a beast.

I imagine that this algorithm would be analogous to that used by UNIX
diff.  I don't know how smart that utility is, but you wouldn't want to
declare two files completely dissimilar simpily because one was
preceeded by a blank line.

Thanks for any sugestions.

-alan mead
From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
Newsgroups: comp.lang.c
Subject: Re: Question to test general C knowledge
Date: 21 Dec 92 17:09:17 GMT
Organization: McGill Research Centre for Intelligent Machines

In article <mcdonald.622@aries.scs.uiuc.edu>, mcdonald@aries.scs.uiuc.edu (J. D. McDonald) writes:
> In article <1992Dec18.182206.29158@mksol.dseg.ti.com> mccall@mksol.dseg.ti.com (fred j mccall 575-3539) writes:

>>>  4["this is a test"]
>> We all know what the type and value is (well it's if type char and
>> has value ' ' for those who don't know)

> Well, it has value ' '.

> But is it type char??

Yes.

> If it is an expression, it **can't** have type char, because any
> expression promotes type char to type int.

If it is used in an rvalue context, yes, it gets promoted to int
immediately.  But there are a few contexts where this doesn't happen,
such as when it's an operand of sizeof.  sizeof(4["this is a test"])
must produce 1, or your compiler's broken.

					der Mouse

			    mouse@larry.mcrcim.mcgill.edu
Newsgroups: comp.lang.c
From: daniel@juliet.osf.org (Daniel Dardailler)
Subject: C weirdos
Organization: Open Software Foundation, Motif Team
Date: Tue, 29 Dec 1992 14:30:58 GMT

Does anybody know if there is a specific news group for all the
little useless C programs that does nothing but funny C hackery.
(one example:    
    main(a){a="main(a){a=%c%s%c;printf(a,34,a,34);}";printf(a,34,a,34);}
 the smallest auto-print program)


Xref: sparky comp.lang.c:18781 comp.std.c:3256