HDTenEightyP/NetNews huggingface dataset:
From: svrobins@bra.isnet.inmos.co.uk
Newsgroups: comp.lang.c
Subject: Curses examples ?
Date: 13 Oct 92 10:49:31 GMT
Organization: Inmos Limited

I'm using curses for the first time and could do with some examples to help
me get going. I want to create a simple menu, which allows the user to
move the cursor to each field and then type in a string. I'd like the user
to use the keypad cursor keys for movement, and then a "special" key to
signify complete eg a ctrl or function key. I'd like the user to be able to
edit the strings. 

I want the menu to be re-usable, ie I want to be able to go back and let the
user modify some field(s). 

I'm using curses on a Sparcstation running SunOS 4.1.1

Is there a site that I can ftp examples from? If not does anyone have anything
they could post or email?   

Thanks in advance

Paul Robins

email svrobins@isnet.inmos.co.uk
From: scs@adam.mit.edu (Steve Summit)
Newsgroups: comp.lang.c
Subject: Re: Strings and integer sizes
Summary: correction of errata in previous article
Date: 10 Oct 92 04:50:42 GMT
Article-I.D.: athena.1992Oct10.045042.12841
Organization: none, at the moment

In article <1992Oct9.173755.18595@athena.mit.edu>, a bit addled,
perhaps, after having (unsuccessfully) tried to burn my house
down the night before, I wrote:

> 	char a11[5] = "abc";
> 	char a12[5] = {'a', 'b', 'c', '\0'};
> 	char a13[5] = {'a', 'b', 'c', '\0', '\0'};
> 
> These define 5-character arrays, with their first four characters
> containing the string "abc".  For a12 and a13, the fifth
> character will be a '\0' if the arrays are global, external, or
> static (if they have "static duration," in the ANSI C
> terminology), or it will be unpredictable garbage if the arrays
> are local non-static ("automatic duration").  For a13, the fifth
> character will always be '\0'.

Though I had meant to discuss a11 and a12 in the second
descriptive sentence, the distinction is in fact meaningless: all
three arrays would be initialized with their fifth characters '\0'.
Somehow I had misread a later clause in ANSI X3.159 section
3.5.7, which clearly says:

	If there are fewer initializers in a brace-enclosed list
	than there are members of an aggregate, the remainder of
	the aggregate shall be initialized implicitly the same as
	objects that have static storage duration.

(My brain must have thought it had seen a last line reading
"objects that do not have explicit initializers.")

Thanks to Jutta Degener for pointing this out.

In point of fact, this case (too few initializers in a string
literal initializer) runs into the same difficulty as the too-
many-initializers case, namely that the language in the Standard
covers explicitly mismatches only in brace-enclosed initializer
lists, which string literal initializers needn't be.  This (in my
head, anyway) potential ambiguity is more worrisome for the
too-few case, because it is more likely to come up (and matter)
in a real program.  I'm surprised this hasn't come up before (or
perhaps it has, but the list of X3J11 interpretation rulings
Chris Volpe posted last August doesn't mention it).

					Steve Summit
					scs@adam.mit.edu
Newsgroups: comp.lang.c
From: ae24@iamk4516.mathematik.uni-karlsruhe.de (Peter Januschke)
Subject: Re: Is there is (pascal) WITH equivalent in C?
Organization: University of Karlsruhe, Germany
X-Newsreader: Tin 1.1 PL4
Date: Mon, 12 Oct 1992 11:09:39 GMT

mccall@mksol.dseg.ti.com (fred j mccall 575-3539) writes:
> And just how many totally non-optimizing Pascal compiilers do you know
> of in the real world that are being used for anything where 'better
> and faster code' would matter?

Nowadays any compiler should do some optimisations, but as a "normal"
user would say : You never know...

By the way, some compilers really do "great" optimisations. Sometimes
your optimised programs calculate other ( and wrong ! ) results than
the non-optimised version....


Peter Januschke
University of Karlsruhe, Germany
From: choi4@gaul.csd.uwo.ca (Wai Kin Choi)
Newsgroups: comp.lang.c
Subject: Are pointer just addresses???
Date: 12 Oct 92 23:28:01 GMT
Article-I.D.: julian.1992Oct12.232801.19149
Organization: Computer Science Dept., Univ. of Western Ontario, London, Canada


Hello!!! I have a question about C that I would
like to know the answer. The question is:

  "Are pointers just addresses of memory?"

Thank you for your attention!!!
Xref: sparky comp.lang.c:14869 comp.software-eng:3728 comp.sys.mac.programmer:16853
From: ark@alice.att.com (Andrew Koenig)
Newsgroups: comp.lang.c,comp.software-eng,comp.sys.mac.programmer
Subject: Re: Productivity of a C programmer ?
Date: 13 Oct 92 02:59:03 GMT
Article-I.D.: alice.23865
Reply-To: ark@alice.UUCP ()
Organization: AT&T Bell Laboratories, Murray Hill NJ

In article <mxmora-121092100513@css-mac1.sri.com> mxmora@unix.sri.com (Matthew Xavier Mora) writes:

> In article <BvvIK4.EuJ@news.cso.uiuc.edu>, rolf@geoserv (Rolf Wilson)
> wrote:

> >   And then double it. Most programmers are pretty good at estimating
> > their programming time, but don't seem to realize that they may only
> > get half of their day to program in.

> They also forget to include the time for testing and debugging. :-)

I once saw a project that had a carefully mapped out schedule that
included milestones for each phase: requirements, design, documentation,
unit test, system test, and so on.

The only catch was that they forgot to schedule any time for development.
-- 
				--Andrew Koenig
				  ark@europa.att.com
Newsgroups: comp.lang.c
From: eda395j@monu1.cc.monash.edu.au (G.J. Ewing)
Subject: help needed with curses problem
Summary: When compiling a program under the att environment, the compiler is
Keywords: curses help
Organization: Monash University, Australia.
Date: Mon, 12 Oct 1992 04:40:20 GMT

After compiling a program using curses under the att environment the compiler
reports - undefined:
          _initscr32
          _endwin
          _flushinp
          etc
                 listing all of the curses functions I am using. This seems to
indicate that the compiler is not able to find curses, even though I have 
included the correct header file <curses.h> and compiled the program as follows:       cc -Xa -lcurses prog.c -o prog
also tried cc -Xa -lcurses -ltermcap prog.c -o prog
           cc -Xa -lcurses -ltermlib prog.c -o prog
           cc -Xa -lcurses -ltermcap -ltermlib prog.c -o prog 
           various combinations of the above
   with the same result.

I have initscr() at the beginning of the executable code and endwin() at the endIf anyone out there has any suggestions I would be most obliged to you.
                                   Greg Ewing
                                   Undergraduate computing student
                                   Monash University, Melbourne, Australia.

ZZ
From: hartman@ulogic.UUCP (Richard M. Hartman)
Newsgroups: comp.lang.c
Subject: Re: Strings and integer sizes
Date: 14 Oct 92 19:36:15 GMT
Organization: negligable

In article <9228812.25025@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
>hartman@ulogic.UUCP (Richard M. Hartman) writes:
>
>>And despite my reply to Lars, it's not a #define, it was upgraded
>>to an inline function in the include file:
>>
>>inline char *strncpyz(char *s1, const char *s2, int n)
>>  { char *s; s = strncpy(s1, s2, n); s1[n] = '\0'; return s; }
>>
>>less efficent than the #define (especially w/ that local "char *s")
>>but safer (I suppose....)
>
>Firstly, this is comp.lang.c, not comp.lang.c++.
>(Why do I get the feeling that I am repeating myself?)
>Inline functions are NOT standard C.

Honest, it *was* a #define ... when we switched over to C++
someone "upgraded" our company standard include file.  The
concept still applies.

>Secondly, inline functions are NOT less efficient than #define.
>(Unless the inline function is too complicated for your dumb compiler to
>actually inline.)

It isn't the fact that it's an inline function, it's the fact
that it now declars a local "char *s" that makes it more 
efficient (doesn't it?), the previous definition was merely

	#define strncpyz(d,s,n) { strncpy(d,s,n); s[n] = '\0'; }

which appears even as recently as the article you just replied
to (sans the "#define", although it was preceded w/ the statement
"which I have defined in an include file as").


		-Richard Hartman
		hartman@ulogic.COM

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"186,000 mi/sec.  Not just a good idea, it's the LAW!"
Newsgroups: comp.lang.c
From: andreas@andreas.hact.de (Andreas Kesenheimer)
Subject: Re: Strings and integer sizes
Organization: Halstenbach ACT GmbH
Date: Wed, 07 Oct 1992 08:03:07 GMT

In article <1992Oct2.020632.17574@mccc.edu>, pjh@mccc.edu (P. J. Holsberg) writes:
|> Multiple choice question:
|> 
|> A string is stored
|> 	a. in an array of characters
|> 	b. in an array of characters terminated with 0
|> 	c. in an array of characters terminated with '\0'

Never trust in C-Compilers! To make shure you get what you want, not just only
with the Compiler you personally tested, you should initialise the array you
want to store the string by memset. Otherways you can't be really shure your
string is terminated (remember to allocate not only the stringlength but also
the terminator and also remember that array-counting beginns with 0).

char my_string[15];

(void)memset(my_string, 0, 15);
(void)strcpy(my_string, "Stringcontence");



|> 
|> (T or F) The ANSI Standard for C guarantees that
|> 	sizeof(short) <= sizeof(int) <= sizeof(long)

allways TRUE!!!

|> 
|> I'm interested in your answers and your comments about the questions.
|> 
|> Thanks,
|> Pete

Hope it helped

	Andreas


-- 
Disclaimer 
Andreas Kesenheimer
Internet: andreas@hact.hact.de
Newsgroups: comp.lang.c
From: choup@bionette.cgrb.orst.edu (Ping Chou)
Subject: static/external <=> storage/linkage
Organization: Biological Computing Consortium, OSU, Corvallis, OR.
Date: Tue, 13 Oct 1992 05:33:20 GMT


        I want to say THANKS to those who reply on my previous posting
in which I complained VAX C treats global variable as EXTERNAL and thus
promotes, by default, the variable name to upper case.

        It turned out that I completely mix variable storage and linkage
when I said static and external. I do programming in isolated Turbo C's
IDE or isolated TASM and thus LINKAGE has never been a bit of concern.
Now that I learned the differences, and here is my three-line report,

extern int gloabl_1;  /* external storage, external linkage */
       int global_2;  /* static storage, external linkage */
static int global_3;  /* static storage, static linkage */

        Please let me know if I'm wrong again.

        Since the treatment of external linkage identifier is, according
to ANSI C, implementation dependent, I really got nothing to say when VAX C
caught me the following line of declaration,

double global, GLOBAL;

        I know this is not a good programming style, but hay, case-sensitive
is one of the many things I want for C.

Ping

ps. Fortunately VAX C accepts variable names containing numbers so that I
    don't have use global_one for global_1, et cl. :-)
Newsgroups: comp.lang.c
From: walk@mrcnext.cso.uiuc.edu (Todd Walk)
Subject: gcc
Organization: University of Illinois at Urbana
Date: Thu, 8 Oct 1992 01:54:10 GMT

Where can I find gcc for both msdos and a sequent balance?

Newsgroups: comp.lang.c
From: umnoor@ccu.umanitoba.ca (Nasir Ahmed Noor)
Subject: My Choice of C book!  please comment
Organization: University of Manitoba, Winnipeg, Canada
Date: Tue, 13 Oct 1992 16:08:33 GMT


The best book I have come across for C is "Theory and Problems of Programming
With C" by Byron S. Gottfried. It is published by Mc-Graw Hill under
Schaum's OutLine Series. Have you seen a comparable or better book on C
than this one?

--nasir
umnoor@ccu.umanitoba.ca
Newsgroups: comp.lang.c
From: cs310as@ux1.cso.uiuc.edu (Tonya Yu)
Subject: struct/union
Summary: problem with struct
Keywords: struct
Organization: University of Illinois at Urbana
Date: Wed, 14 Oct 1992 10:19:08 GMT

Hi...
I have a problem using pointer within in struct or at least i think that is 
what the problem is.
Is the following sturct declaration valid?

      typedef struct { int x;
                       int y;
                       FOO *junk_pointer; } FOO;

I am getting an error message telling me to use union?
The C book I have does not fully explain this matter.
Any input will be greatly appreciated.

Thanks in advance.

-Tonya

Newsgroups: comp.lang.c
From: wilson@rhombus.cs.jhu.edu (Dwight Wilson)
Subject: Re: Strings and integer sizes
Organization: The Johns Hopkins University CS Department
Date: Sat, 10 Oct 1992 01:24:13 GMT

In article <718691388snx@grendel.demon.co.uk> jes@grendel.demon.co.uk (Jim Segrave) writes:
>In article <1992Oct9.125347.24160@blaze.cs.jhu.edu> wilson@rhombus.cs.jhu.edu (Dwight Wilson) writes:

[Discussing why 'char zoe[3]="abc";' is allowed]
>
>At a guess, it gives you a way of initialising character arrays
>which may not use a trailing zero convention.
[...]
>an initialiser of:
>struct dir_entry florence = { 2, {'f', 'o', 'u', ... 'r'}};
>is horrible to read - I'm too lazy to even type the whole thing out.
>whereas:
>struct dir_entry florence = { 2, "fourteenchar"};
>is not so bad. The compiler will complain if you make it too long, and,
>if it's only "xivchar", it will pad it out with zeros for you.
> 

Careful, only in static variables will it be padded with zeroes.
If the initializer is too short, an automatic variable will be
nul terminated but there will be garbage after the nul.

It's true that this looks nicer, but I think that it's too risky.
Perhaps I wasn't very explicit about this in my original post.  If you
have a declaration of the form

char a[3] = "abc";

Someone else looking at the program is likely to assume that
'a' is simply a null terminated string, particularly with longer
strings where the length is not immediately obvious.  If the
code is changed to pass 'a' to strlen(), strcpy(), etc., a
bug will be introduced.  This bug may be quite difficult to find
since it probably won't cause an immediate fault.  I vaguely
remember seeing an example of this initialization used in an
add for Gimpel Software's version of lint.

An initialization like "char a[3] = { 'a', 'b', 'c' };" makes
it clear that this is not a nul terminated string.  Does the convenience
of the first form outweigh the possible risk?  Personally, I don't
think so, the code code should either be designed to use nul terminated
strings, or the array initialization form used.

-Dwight
Newsgroups: comp.lang.c
From: walduck@mpr.ca (Andrew Walduck)
Subject: Re: Curses to write to stderr, possible?
Organization: MPR Teltech Ltd., Burnaby, B.C., Canada
Date: Wed, 7 Oct 92 17:54:21 GMT

In article <1992Oct6.034638.29275@oucsace.cs.ohiou.edu> tswingle@oucsace.cs.ohiou.edu (Tom Swingle) writes:
>Would there be any problem with using memcpy instead of assignments?  I got
>the following program to work, and our system does #define stdin, stdout, and
>stderr rather than declare them as variables:
>
>#include <stdio.h>
>#include <memory.h>
>#include <malloc.h>
>
>main() {
>
>  FILE *temp;
>
>  temp=(FILE *) malloc(sizeof(FILE));
>  memcpy((char *) temp,(char *) stdout,sizeof(FILE));
>  memcpy((char *) stdout,(char *) stderr,sizeof(FILE));
>  fputs("Hello there, this is stdout changed to be stderr\n",stdout);
>  memcpy((char *) stdout,(char *) temp,sizeof(FILE));
>  fputs("Hello there, this is stdout back to its old self again\n",stdout);
>  return 0;
>
>}
>
>As expected, invoking "a.out" causes both lines to be printed, while 
>"a.out > /dev/null" causes only the first one to be printed.  These files
>were probably only meant to be opened, closed, read, and written; although
>I can't think of any problems that might arise by directly manipulating 
>them, it doesn't mean there aren't any.  Can anyone think of such problems?  

Yes...its 110% non-portable...and it may not even work for the next
release of the C compiler... don't do this silliness...

All FILE objects, and especially the stdout/stdin/stderr are magic...

What if fputs was coded like this??
{ stdout, stdin, stderr are *MAGIC* address...}

int fputs(char*s, FILE* stream)
{
  if(stream == stdout)
    // handle the stdout stream...
  else
  if(stream == stdin)
    // handle the stdin stream...
  else
  if(stream == stderr)
    // handle the stderr stream...
  else
  {
    // its a user defined stream from fopen...
    // dereference the pointer and play...
  }
}

This library implementation will break your code!

Andrew
P.S. Go read a good book about the ANSI C standard...
     Plauger and Brodie is good...
-- 
Andrew Walduck, MPR Canada, walduck@mprgate.mpr.ca
-------------------------------------------------------------------------------
(I hope someone will flatter me by using this as a .sig quote...)
 -- Reid Kneeland
Newsgroups: comp.lang.c
From: Nico Tranquilli
Subject: Re: How to execute "setenv ..." in c program???
X-Xxmessage-Id: <A6F9B42654010B1A@mac1.di.unipi.it>
X-Xxdate: Thu, 8 Oct 92 08: 47:18 GMT
Organization: Computer Science Dept. , University of Pisa
X-Useragent: Nuntius v1.1.1d9
Date: Thu, 8 Oct 1992 08:50:20 GMT

In article <yho.718475522@cunews> Y. Ho, yho@janet.carleton.ca writes:
>Since setenv is not a "sh" command, "system" function can't be used.
>How can I do then?

simply call setenv("VARIABLE=abcderegf"), and this will update the
current environment; on the other hand, if you use a "system" function
it would work on child's process (shell) environment.

--nico.
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.lang.c
Subject: Re: Is there is (pascal) WITH equivalent in C?
Date: 8 Oct 92 09:43:53 GMT
Organization: Comp Sci, RMIT, Melbourne, Australia

In article <1992Oct6.170156.5841@mksol.dseg.ti.com>, mccall@mksol.dseg.ti.com (fred j mccall 575-3539) writes:
> And just how many totally non-optimizing Pascal compiilers do you know
> of in the real world that are being used for anything where 'better
> and faster code' would matter?

I have just been study a textbook on Turbo Pascal 6.0.  It shows some
code generated by TP which could obviously benefit from either postponing
register allocation until after the procedure body has been analysed or
else just a wee bit more peephole optimisation, and says that this happens
because TP6 is a one-pass compiler.

So the answer could well be "nearly all of them".  TP is very popular,
for many good reasons.  Fast compilation, small executables, good support
for embedded assembly code, ...

Newsgroups: comp.lang.c
From: sasghm@theseus.unx.sas.com (Gary Merrill)
Subject: Re: (double)=(double)-(int)*(int) valid???
Originator: sasghm@theseus.unx.sas.com
Date: Thu, 15 Oct 1992 20:11:41 GMT
Organization: SAS Institute Inc.


In article <1992Oct15.062145.1212@trl.oz.au>, hui@apaturia.trl.OZ.AU (Alvaro Hui) writes:

|> 	Apparently, the compiler compute c*d in a temp variable
|> of size 'int' before doing a convertion to 'double'!!!!!! How
|> can the compiler assume multiplying two integer will always fit
|> into an int!!!!

And just what do you think it *should* assume?  Try reading the
language standard.
-- 
Gary H. Merrill  [Principal Systems Developer, C Compiler Development]
SAS Institute Inc. / SAS Campus Dr. / Cary, NC  27513 / (919) 677-8000
sasghm@theseus.unx.sas.com ... !mcnc!sas!sasghm
Newsgroups: comp.lang.c
From: singg@alf.uib.no (Kurt George Gjerde)
Subject: XDrawLine/Modula-2
Organization: University of Bergen, Norway
Date: Sat, 10 Oct 92 13:11:10 GMT


X-windows <--> Modula-2
-----------------------

I've just started on a project (Modula-2) that includes
drawing lines (graphics) on screen (in a window).

The Modula-2 compiler we use can't do that. So I have
to write the graphic routines in C and link it with 
my M-2 program.

I guess I have to write C_routines for popping up a 
drawing-window and for drawing lines in that window.


Can anyone help me????

The modula-2 compiler is: EPC Modula-2 (you've probably
never heard of that one)

I can use the Xlib, Xt and Xm  C-libraries.


Please anyone...!!


Kurt.


Newsgroups: comp.lang.c
From: caro@uni-paderborn.de (Carsten Rose)
Subject: Re: ### Question about setitimer ####
Organization: Uni-GH Paderborn
X-Newsreader: TIN [version 1.1 PL6]
Distribution: usa
Date: Thu, 8 Oct 1992 11:31:31 GMT

Hi,

1) You initialize 'itimerval' not correctly. 
   The counted time isn't in 'it_interval' but in 'it_value'.
   'it_interval' is the value which is reloaded when the timer
   expires (you don't need this). Setting 'it_value' to zero, 
   disables the timer (you don't initialize it) !

2) You have to catch the Signal 'SIGALRM'

So this is the right code:

-----------------------------------------------------------------

#include <stdio.h>
#include <sys/time.h>

#include <signal.h>

catch()
{
	puts("Yeah, I cought the signal");
}

main(argc,argv)
int argc;
char **argv;
{
    struct itimerval value;
    struct itimerval ovalue;

    if (argc < 2)  {
	       printf("Usage: usleep <usecs>\n");
          exit(0);
    }

    value.it_interval.tv_sec = 0;
    value.it_interval.tv_usec = 0;
    value.it_value.tv_sec = 0;
    value.it_value.tv_usec = atol(argv[1]);

    if(signal(SIGALRM,catch)==(void *)-1) {
	perror("Installing Signal failed:");
	exit(1);
    }

    setitimer(ITIMER_REAL, &value, &ovalue);

    pause();

    printf("Out of pause.\n");

}


-----------------------------------------------------------------

Ciao
	Carsten

--
Carsten Rose, Germany           | Life. That's what happens while
EMail : caro@uni-paderborn.de   | you're thinking about the future
Newsgroups: comp.lang.c
From: marusek@rahul.net (Peter M. Marusek)
Subject: FAW for pc c compilers
Organization: a2i network
Distribution: usa
Date: Mon, 12 Oct 1992 02:44:49 GMT

Is there a FAQ avail for the capabilities etc of the various C compilers
for the PC?  I am particularly interested in Turbo and Zortec...
I have an older version of Turbo c/c++ and wonder what I get in the 3.x
versions...like ems support maybe???  Do they have a memory extender stub?
I understand Zortec does?
Will the Windows turbo c/c++ compiler give me full ems mem support etc and
will it generated programs that will run w/o windows as well as with, and is
it a good devel platform for windows applications?
thanx
cheers
Peter Marusek

-- 
Peter M. Marusek <marusek@rahul.net>
Newsgroups: comp.lang.c
From: gurgle@netcom.com (Pete Gontier)
Subject: Re: C++ for Mac
Organization: cellular
Date: Thu, 15 Oct 1992 15:06:17 GMT

dlsteven@nyx.cs.du.edu (Doug Stevens) writes:

>Does anyone know if Borland has a Turbo C or Turbo C++ for Macintosh?

If they did, they wouldn't be able to keep enough in stock for
their employee programmers.
-- 
 Pete Gontier // EC Technology // gurgle@netcom.com
Newsgroups: comp.lang.c