HDTenEightyP/NetNews huggingface dataset:
From: kugold@kuhub.cc.ukans.edu
Newsgroups: comp.lang.c
Subject: Few simple questions
Date: 21 Jan 93 00:10:21 CST
Organization: University of Kansas Academic Computing Services

L.S.

I have a few questions (I am programming in ANSI-C on a UNIX machine) :

1. In unix, the backspace key does not work properly. I already 
   found out that this can be changed by typing stty erase ^?, where '^?' 
   means ctrl-?. I tried to include this in my .login file, but emacs does 
   not accept ^?. How do I put this line in my .login file?

2. In C I need an input function like INKEY$ in BASIC, that is a function that
   does _not_ wait for input, but just an empty string or so returns if no 
   character is entered. (I am trying to measure the time between two key-
   presses). Does this function exist, and if not, is there any way to do
   what I want?

3. In C again, I want to initialize and array of integers, like
   
   main()
   {
     int ttime[6]={0,0,0,0,0,0}
     /* rest of program */
   }

   but the compiler keeps saying:
    
" 
ccom: Error: tr.c, line 12: no automatic aggregate initialization
        int     ttime[6]={0,0,0,0,0,0};
      ------------------^
ccom: Error: tr.c, line 12: illegal lhs of assignment operator
        int     ttime[6]={0,0,0,0,0,0};
      ---------------------^
ccom: Error: tr.c, line 12: illegal lhs of assignment operator
        int     ttime[6]={0,0,0,0,0,0};
      -----------------------^
ccom: Error: tr.c, line 12: illegal lhs of assignment operator
        int     ttime[6]={0,0,0,0,0,0};
      -------------------------^
ccom: Error: tr.c, line 12: illegal lhs of assignment operator
        int     ttime[6]={0,0,0,0,0,0};
      ---------------------------^
ccom: Error: tr.c, line 12: illegal lhs of assignment operator
        int     ttime[6]={0,0,0,0,0,0};
      -----------------------------^
ccom: Error: tr.c, line 12: illegal lhs of assignment operator
        int     ttime[6]={0,0,0,0,0,0};
      -------------------------------^
"

   I really don't see what is wrong, the more because in my c-book,
   "C by discovery" by L.S. Foster on page 213, almost exactly the
   same thing is done.

Thanks a lot in advance for any answer and I am sorry if the UNIX question 
doesn't belong in this newsgroup.

Regards,

Wimjan

kugold@kuhub.cc.ukans.edu 
Newsgroups: comp.lang.c,comp.os.msdos.programmer
From: rnichols@cbnewsg.cb.att.com (robert.k.nichols)
Subject: Re: Reading the arrow keys... how?
Organization: AT&T
Date: Fri, 22 Jan 1993 01:06:07 GMT

In article <1jmeupINN4g9@savoy.cc.williams.edu> 93gke@williams.edu (Just Ask The Axis) writes:
>I am trying to read the arrow keys from a PC keyboard in C. So far
>the calls to getch(), getc(), getchar(), have been unsuccessful
>because the keys don't seem to have a corresponding ASCII code (they
>seem to send 2 characters..?) I also need to read some regular keys
>like Q,S, etc... 

You can use getch() to read the arrow keys.  The extended keys all
return a 2-byte sequence, with the first byte being either 0 or 0xE0.
When you see one of those values, the next call to getch() will return
a code that indicates the key.  Header file EXTEND.H, if you have it,
contains definitions for the key codes -- I don't recall where I dug
them up.  Here are a few values:

	#define HOME         71
	#define CTRL_HOME   119
	#define END          79
	#define CTRL_END    117
	#define ARROW_UP     72
	#define ARROW_DOWN   80
	#define ARROW_LEFT   75
	#define ARROW_RIGHT  77

Bob Nichols
AT&T Bell Laboratories
rnichols@ihlpm.ih.att.com
From: csc5840@hertz.njit.edu (Sekhar Chitti)
Newsgroups: comp.lang.c
Subject: Could someone answer my question....thanks
Date: 26 Jan 93 00:01:05 GMT
Organization: New Jersey Institute of Technology, Newark, N.J.

Hi Netters,


Following is a C program in which I tried to simulate command
line arguments (argc, argv). I am not getting the expected
output which should be the same as when argc, argv are used.



#include <stdio.h>

main(arg1,arg2)
int arg1;
char *arg2[];
{
	int i;
	for(i=0;i<arg1;i++)
		puts("%d - %s",i,arg2[i]);
}


The following is the output when I tested the program for diff no.
of arguments. The 'for' loop iterates exactly the number of arguments,
but when I tried to print the number of args, as u can see from the
output, I am getting it wrong...

6:45pm C-> a.out arg2
%d - %s
%d - %s
6:45pm C-> a.out arg2 arg3
%d - %s
%d - %s
%d - %s
6:46pm C-> a.out arg2 arg3 arg4
%d - %s
%d - %s
%d - %s
%d - %s
6:46pm C-> a.out 
%d - %s


Could somebody suggest me in this regard ? Thanks in advance.

Sekhar Chitti
From: banshee@cats.ucsc.edu (Wailer at the Gates of Dawn)
Newsgroups: comp.lang.c
Subject: Re: How do you read binary data piped into stdin?
Keywords: stdin, redirection, binary data
Date: 22 Jan 93 20:05:10 GMT
Organization: University of California, Santa Cruz
NNTP-Posting-Host: am.ucsc.edu


chorn@eastwind.mcds.com (Christopher Horn) writes:
>I'm relatively new to C, so still have a lot to learn, so I apologize
>if this is a silly question. I need to read raw binary data from
>stdin (it is being piped in) but it appears stdin operates in text
>mode. The first ascii 26 that comes along triggers end of file, and
>I can't read the rest of the data. Could someone please explain, or
>better yet show me a short peice of code, that could do this? The
>answer is probably obvious, but it eludes me at the moment. Thanks
>a lot!

Basically I'd think you'd want to close fd 0 (stdin) and open a new input
in a binary mode.  Difficulty will differ depending on the system you're on.

-- 
The Wailer at the Gates of Dawn              | banshee@cats.UCSC.EDU       |
Just who ARE you calling a FROOFROO Head?    |                             |
DoD#0667  "Just a friend of the beast."      | banshee@ucscb.UCSC.EDU      |
2,3,5,7,13,17,19,31,61,89,107,127,521,607....| banshee@ucscb.BITNET        |
Newsgroups: comp.lang.c
From: las@camaro.uucp (Laszlo Herczeg)
Subject: how do I search for <lf>, (ASCII(10))?
Organization: camaro
Date: Mon, 25 Jan 1993 06:16:10 GMT

Hello big programmers:
How do I search for the line-feed (instead of the EOF character) when
reading a string from a file.
 
Here is what I have right now:
if(fgets(path,sizeof(path),fp) !=EOF){
 
Now, my problem is that fgets also returns ASC(10) and ASC(13), and I
don't know how to get rid of them.
 
The program I am writing is supposed to read the batch file pat.bat
which contains the current path. I'd like to manipulate the contents
of this file, and then write back to it, but when I do, C preserves
the line formatting characters, so the revised pat.bat does not
execute properly.
 
I have gotten around the problem temporarily by manually removing the
control chracters from the file, but there must be a better way.

So I have two questions:
1. Is it possible to search for asc(10) specifically, and stop there?
2. If not, is it possible to strip the string stored in "path" of the
EOF characters?
 
Many thanks in advance,
Laszlo 
 
-- 
***************************************************************************
Laszlo Herczeg         e-mail:las@camaro.UUCP (running on LINUX 0.99)
                       e-mail:las@eastern.com
                       e-mail:las@r-node.gts.org
         "Many a good hanging prevents a bad marriage,..."
From: tomster@bigwpi.WPI.EDU (Thomas Richard Dibble)
Newsgroups: comp.lang.c
Subject: Re: Learning c++
Date: 21 Jan 93 22:23:29
Organization: ZikZak Corporation
	<00966E60.98255E60@Msu.oscs.montana.edu>
NNTP-Posting-Host: bigwpi.wpi.edu
In-reply-to: gjb7307@Msu.oscs.montana.edu's message of Wed, 20 Jan 1993 22:32:45 GMT

t>>>>> On Wed, 20 Jan 1993 22:32:45 GMT, gjb7307@Msu.oscs.montana.edu said:

  g> In article <1993Jan19.233110.2873@ringer.cs.utsa.edu>, pnarsipu@ringer.cs.utsa.edu (Praasad Y. Narsipur) writes:
>I want to C++ language. I`m a moderate C programmer.  Suggest me book
>so that i can learn C++ programming.  Some say that if he is a good
>programmer in C, then it is difficult
>to learn C++(rather shift over to C++)Is that true. Also tell me the

  g> not exactly, i think what you have heard is that it is difficult
  g> to go from structured programming to object-oriented programming
  g> simply because we try to impose limitations and look at future
  g> problems when we should be focusing on the NOW.  The limitations
  g> and future problems usually turn out not to exist.

The two are definitely different metaphors to programming, which is
what causes programs -- un-learning one approach is just as difficult
as learning the other.

>difference between Borland C++ and Turbo C++. I'm confused by this.

  g> _Currently_, Borland C++ is the DOS environment, whereas Turbo
  g> C++ is the Windows environment.

How I understand it is that BC++ is more geared towards the
"professional" programmer whereas TC++ is aimed at the "novice" or
"amateur".  The TC++ packages, in general, do not contain the breadth
of tools the BC++ packages do.  They do, however, contain the same
quality of product (which is high by all counts).  Look over the
"Features" list of the two boxes for samples; you should find quite a
few.  Also, several "optional tools" of TC++ are standard in BC++.
(Sorry I can't be more specific ... I haven't actually pored over the
features lists myself for quite some time now.)  I believe the editors
(of the same version programs) are identicle.  Both are on ver 3.1
now.  
	TC++ for DOS is ~$70, TC++ for Windows is ~$120; BC++ for both
is (highly dependent of if you get Applications Frameworks, et al)
~$380 for DOS/Windows.  I think the App. FW pushes that up to ~$700+.

>Please let me know about this. Thanks in advance.

		---- tomster@wpi.wpi.edu


--
/****************************************************************************\
| "I sometimes used to try to catch her, :	FROM:   tomster@wpi.wpi.edu  |
| but never even caught her name."	 :	TO:	who(m)ever reads it  |
|	---- the cure			 :	CC:	programming language |
\vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/
Newsgroups: comp.lang.c
From: george@tessi.com (George Mitchell)
Subject: The Coming Crisis
Summary: The world is coming to an end.
Keywords: asctime,crisis
Organization: Test Systems Strategies, Inc., Beaverton, Oregon
Date: Tue, 26 Jan 1993 18:55:43 GMT


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)
Newsgroups: comp.lang.c,comp.lang.fortran
From: bobp@msi.com (Bob Pitha)
Subject: Re: calling a Fortran subroutine from a C program
Followup-To: comp.lang.c,comp.lang.fortran
Organization: Molecular Simulations, Inc.
Date: Sat, 23 Jan 1993 02:58:35 GMT
X-Newsreader: TIN [version 1.1 PL8]
X-Posted-From: phoenix.msi.com
NNTP-Posting-Host: sol.ctr.columbia.edu

Michael Lemke (michael@chpc.utexas.edu) wrote:
: To make it really clear:  The difference is

: 	CHARACTER*100 STRING

: or

: 	CHARACTER*1 STRING(100)

: which are very different data structures.   The latter is an array, the
: first is a single variable.  I don't care how C chews its memory, it can
: hardly distinguish these two cases.  The last is pretty close in
: functionality to C's concept (except for having a length stored
: somewhere) as you'd need something like strcpy to copy data.

  Of course they're different in FOrtran; you could hardly do the
following:
      character*1 string (100)

      string = "blahblahblah"

  But that wasn't my point.  My point was, I was talking about passing
an *array or characters* from C.  Rather than write "array or characters"
I wrote "character array"; but I was not talking about a Fortran array
of strings.  I read the question origianlly in comp.lang.c, and in c
the ambiguity does not exist.  I'm sorry if I confused you.  I think
we both know what I meant and what you mean, so let's just leave it.

-----------------------------------------------------------------------
Bob Pitha                      Molecular Simulations Inc.
bobp@msi.com                   16 New England Executive Park
(617) 229-9800 x242            Burlington, MA 01803-5297
From: pat@rwing.UUCP (Pat Myrto)
Newsgroups: comp.lang.c
Subject: Re: Prototyping
Keywords: K&R C, ANSI C
Date: 22 Jan 93 18:09:43 GMT
Organization: Totally Unorganized

In article <1993Jan20.154751.3809@news.unige.ch> favre@medsun.unige.ch (Eric Favre) writes:
>
> [ ... ]
>I'm trying to convert C files written in the old-fashioned
>Kernighan and Ritchie C to Standard (or ANSI, as you prefer) C.
>My main problem concerns the function prototyping. Do you
>know a UNIX shell script or a program that can help me to convert
>function declarations and create function prototypes?


Look for a utility named 'cproto'.  I'm sure its on uunet (anon uucp)
or most archive sites.  Header says comp.sources.misc Volume 29, Issue
61, originally a 2 part posting.  This will convert K&R to ANSI prototyped
form, changing the function definitions to the ANSI syntax, and generating
the prototypes, which are sent to stdout. It has options for things like
prototypes with guard macros, so the same header can be used with either
K&R or ANSI.  It also does the reverse conversion, converting ANSI
prototyped code to the K&R form if desired.

It has worked fine for me, though I use it mostly to de-ANSIfy source
code.  Your mileage may vary.

>Thank you for any help.

Yer welcome...  :-)

-- 
pat@rwing.uucp                                  (Pat Myrto),  Seattle, WA
                      If all else fails, try:
         ...!uunet!{pilchuck, polari}!rwing!pat
WISDOM:    "Travelling unarmed is like boating without a life jacket"
From: gegu@zurich.spectrospin.ch (Gerry Gucher)
Newsgroups: comp.lang.c
Subject: Re: HALLOC and HUGE ptrs in Microsoft C
Summary: oops
Date: 24 Jan 93 23:54:37 GMT
Distribution: world,local
Organization: Spectrospin AG, Fallanden Switzerland

In article <206@zurich.spectrospin.ch>, gegu@zurich.spectrospin.ch (Gerry Gucher) writes:



>   instead :  fwrite( buf, 200000, sizeof(int), fp );
>   try     :  fwrite( buf, 2000, 1000*sizeof(int), fp );
> 
> I have not tried it but it might work.

Oops, I blew it. It sure wouldn't work. Should say

    try     :  fwrite( buf, 200, 1000*sizeof(int), fp );

Gerry

Xref: sparky comp.lang.c:20048 comp.lang.c++:19725
From: 93gke@williams.edu (Just Ask The Axis)
Newsgroups: comp.lang.c,comp.os.msdos.programmer
Subject: Reading the arrow keys... how?
Date: 21 Jan 1993 15:19:53 GMT
Organization: Williams College, Williamstown, MA
NNTP-Posting-Host: hancock.cc.williams.edu

I am trying to read the arrow keys from a PC keyboard in C. So far
the calls to getch(), getc(), getchar(), have been unsuccessful
because the keys don't seem to have a corresponding ASCII code (they
seem to send 2 characters..?) I also need to read some regular keys
like Q,S, etc... 
Could someone tell me how to read them directly, please.

Greg Ennis
93gke@cs.williams.edu
From: pinstall@rc1.vub.ac.be (Installe P.)
Newsgroups: comp.lang.c
Subject: C style : #define versus enum
Date: 27 Jan 93 17:28:21 GMT
Distribution: world
Organization: Brussels Free Universities (VUB/ULB), Belgium

Hello,

I usually see a serie of #define in the include files. Why ?

Is there a space/speed influence of the preprocessors directives ?

Is the #define used for system compatibility and enum easier for 
developpment purpose ?



Patrick Installe (pinstall@vub.ac.be) 
Newsgroups: comp.lang.c
From: ctoth@magnus.acs.ohio-state.edu (Christopher M Toth)
Subject: Best way to learn C?
Organization: The Ohio State University
Date: Mon, 25 Jan 1993 05:48:14 GMT

	Does anyone have good advice on the best way to learn C? I have
K&R's book, but, in order to learn the stuff, I would like to write
programs for practice, but can't come up with any good ones. Any adivice
would be greatly 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
From: scjones@thor.sdrc.com (Larry Jones)
Newsgroups: comp.lang.c,comp.std.c
Subject: Re: offsetof in case labels
Date: 24 Jan 93 18:27:54 GMT
Followup-To: comp.std.c

In article <1993Jan21.232337.6527@g2syd.genasys.com.au>, roberts@g2syd.genasys.com.au (Robert Swan) writes:
> We have a problem on various machines using the offsetof macro from
> stddef.h in case labels.  These machines all reject the expression as
> being non-constant.

Those compilers are not ANSI/ISO conforming.  The ANSI/ISO C Standard
clearly requires offsetof to expand to an integral constant expression
which, as you noted, is exactly what is required for a case label. 
(Since this is a standards question, I've also posted this to comp.std.c
and redirected follow-ups there.)

> A representative of one of the machine vendors (IBM), has glibly stated
> that the compiler is doing the right thing by rejecting it.

He is mistaken.  By an amazing coincidence, X3J11 has received a request
for interpretation from someone at IBM on exactly this point.  This RFI
points out that it is not possible to write an offsetof macro that
expands to strictly conforming code (which is precisely why the macro
exists -- if you could do it yourself, the macro would be redundant) and
arguing that this makes any program that uses offsetof not strictly
conforming and thus an implementation is free to reject it.  This is, of
course, nonsense -- an otherwise strictly conforming program that uses
offsetof in a strictly conforming fashion is still strictly conforming
reguardless of the expansion of the macro.  The RFI, suspecting this to
be the committee's response, goes on to point out that this *requires*
an implementation to implement an extension of some sort in order to
implement offsetof and argues that this is inappropriate.  While this is
the most common method of implementing offsetof (generally by extending
the implementation's definition of constant expression, which the
standard allows, or by adding a new keyword), it is not, strictly
speaking, necessary.  All that is required is an omniscient preprocessor
that can expand offsetof to the correct integer constant -- not a
difficult task if the preprocessor is an integral part of the compiler
with access to the symbol table.

(These are my recollections of the RFI and the committee's discussions
-- there is no guarantee that they match anyone else's recollections or
the actual facts.  Those who care should obtain the collected Requests
for Interpretation and Responses which ANSI should be publishing as a
Technical Information Bulletin real soon now.)

> However, I'm pretty much at sea with the ANSI standard - we don't have a
> copy, and the excerpts I have seen of it suggest that it is written in
> sufficiently obscure legalese to cloud the superficial interpretation I
> might put on it.

On the contrary, it's actually quite readable for a language standard; a
bit more difficult than K&R Appendix A, perhaps, but not significantly
so.
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
larry.jones@sdrc.com
Pitiful.  Just pitiful. -- Calvin
From: harald@marilyn.bion.kth.se (Harald Winroth)
Newsgroups: comp.lang.c
Subject: Re: Unwanted float to double conversion in variable length arg lists?
Date: 22 Jan 93 12:38:50 GMT
Organization: Royal Institute of Technology, Stockholm, Sweden

In article <C18924.2yp@inews.Intel.COM> dmarer@td2cad.intel.com (Dennis Marer) writes:

>  I've got a curious problem when passing floats in a variable length argument
>  list...they are automatically converted to doubles, EVEN when I typecast.
>  Consider:

From K&R, 2nd ed:

...trailing arguments beyond the explicitly typed parameters suffer default
argument promotion...

which means that all float parameters corresponding to ... are promoted to 
doubles (just like ALL float parameters were promoted in old K&R C).

-----------------------------------------------------------------------------
Harald Winroth      |  Computational Vision and Active Perception Laboratory,
harald@bion.kth.se  |  Royal Institute of Technology, Stockholm, Sweden.
-----------------------------------------------------------------------------
From: kdq@quest.UUCP (Kevin D. Quitt)
Newsgroups: comp.lang.c
Subject: Re: Turbo C FOPEN error
Date: Wed, 27 Jan 93 18:05:41 PST
Reply-To: srhqla!quest!kdq
Organization: Job quest  (805) 251-8210,  So Cal: (800) 400-8210

gilmour@binah.cc.brandeis.edu (Jeffrey R. Gilmour) writes:
> I can't figure out what's wrong.  This program works fine as long as there's
> less than 16 files (it doesn't actually matter what drive).  I haven't come
> across anything explaining it in the manual.  The error happens at runtime 
> during the 'stream = fopen(name...' line.  Anybody?
...
>         done = _dos_findfirst("a:*.*", _A_NORMAL, &test);
>         while (!done) {
...
>                 if ((stream = fopen(name, "r")) == NULL) {
...
>                 }
>  
>                 done = _dos_findnext(&test);
>         }
>         fclose(stream);
> }

    Real easy - you're running out of file descriptors since you
never close the files you're opening.  Move the fclose to just above
the _dos_findnext and your problem will disappear.


 _
Kevin D. Quitt      96.37% of all statistics are made up.     srhqla!quest!kdq
Newsgroups: comp.lang.c
From: mccurley@cs.sandia.gov (Kevin S. McCurley)
Subject: program to split a large file of C functions
Originator: mccurley@jemez.cs.sandia.gov
Organization: Sandia National Laboratories, Albuquerque, NM
Distribution: usa
Date: Sun, 24 Jan 93 00:29:18 GMT

Perhaps I am ignorant, but is there a program available somewhere (in
source form, preferably) that will split a single file of many C
routines into multiple files, one for each function?  Ideally I want
something that could handle static global variables, put the includes
into all of the files, and handle any legal C syntax.

Kevin McCurley
Sandia National Laboratories




Newsgroups: comp.lang.c
From: dfuller@portal.hq.videocart.com (Dave Fuller)
Subject: Re: Could someone answer my question....thanks
Organization: VideOcart Inc.
X-Newsreader: Tin 1.1 PL3
Date: Tue, 26 Jan 1993 00:18:43 GMT

I assume you want output to go to stdout since you use puts().
I also assume you like the inserted \n that puts gives you.

Making such assumptions, you just need to change

    puts("%d - %s",i,arg2[i]);

to

    fprintf(stdout, "%d - %s\n", i, arg2[1]);


Dave Fuller
dfuller@portal.hq.videocart.com
 
Newsgroups: comp.lang.c,vmsnet.alpha,cern.alpha
From: burow@dxcern.cern.ch (Burkhard Burow)
Subject: function arg.'s in Alpha's DEC C
Organization: CERN European Laboratory for Particle Physics
Date: Sat, 23 Jan 1993 19:41:39 GMT


I'm having trouble passing functions as arguments on an Alpha running VMS and
'DEC C for OpenVMS AXP V1.2-000'

My application generates 'wrapper' routines which pass along functions to
other routines. The wrapper routines do not know the type of the functions they
are passing along.

Simplified e.g.

void q ( int (*c)() );     /* A. prototype of q                              */

void __q( void ( *a)() )   /* B. function with a function as argument        */
{
q( a );                    /* C. pass the function parameter on to q.        */
}

For which the C compiler complains:

q( a );
^
%CC-E-PASNOTREFCOM, In this statement, the referenced type of the pointer value
"a" is "Function (...) returning void", which is not compatible with "Function (
...) returning signed int".
at line number 5


Silicon Graphics 2.0.1 ANSI generates a similar warning, but can be satisfied
by casting 'a' in line B. as follows:

q( *(void **)&a );        

Other compilers swallow line B. as is.

QQQuestion: How do I force DEC C to accept line B.
            i.e. How do I cast the parameter 'a', such that it is acceptable
                 as a an argument for any type of function?

thanks,
burkhard      burow@vxdesy.cern.ch
Xref: sparky comp.lang.c:20061 comp.std.c:3397