home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20050 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  3.2 KB

  1. Path: sparky!uunet!noc.near.net!bigboote.WPI.EDU!nntp!tomster
  2. From: tomster@bigwpi.WPI.EDU (Thomas Richard Dibble)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Few simple questions
  5. Date: 21 Jan 93 22:07:33
  6. Organization: ZikZak Corporation
  7. Lines: 67
  8. Message-ID: <TOMSTER.93Jan21220733@bigwpi.WPI.EDU>
  9. References: <1993Jan21.001022.46578@kuhub.cc.ukans.edu>
  10. NNTP-Posting-Host: bigwpi.wpi.edu
  11. In-reply-to: kugold@kuhub.cc.ukans.edu's message of 21 Jan 93 00:10:21 CST
  12.  
  13. >>>>> On 21 Jan 93 00:10:21 CST, kugold@kuhub.cc.ukans.edu said:
  14.  
  15.   k> L.S.
  16.  
  17.   k> I have a few questions (I am programming in ANSI-C on a UNIX machine) :
  18.  
  19.   k> 1. In unix, the backspace key does not work properly. I already 
  20.   k>    found out that this can be changed by typing stty erase ^?, where '^?' 
  21.   k>    means ctrl-?. I tried to include this in my .login file, but emacs does 
  22.   k>    not accept ^?. How do I put this line in my .login file?
  23.  
  24. Yeah, this doesn't really fit in this newsgroup, but oh well.  Try
  25. pressing the "`" (backwards single quote --top, left key on keyboard)
  26. before hitting Ctrl-?.  The input buffer of Emacs (the bottom line,
  27. below the reverse-text or whatever bar) will say "Quote:".  The only
  28. problem with this is that some comm programs reserve use of the "`"
  29. key for internal use (like activating a menu or somesuch).  Then what
  30. you need to do depends on the program you are using.
  31.  
  32.   k> 2. In C I need an input function like INKEY$ in BASIC, that is a function that
  33.   k>    does _not_ wait for input, but just an empty string or so returns if no 
  34.   k>    character is entered. (I am trying to measure the time between two key-
  35.   k>    presses). Does this function exist, and if not, is there any way to do
  36.   k>    what I want?
  37.  
  38. I know of no such beast on UNIX machines.  In DOS under TC 2.0 there
  39. is kbhit(), but I have found no equivalent for UNIX.
  40.  
  41.   k> 3. In C again, I want to initialize and array of integers, like
  42.   k>    
  43.   k>    main()
  44.   k>    {
  45.   k>      int ttime[6]={0,0,0,0,0,0}
  46.   k>      /* rest of program */
  47.   k>    }
  48.  
  49.   k>    but the compiler keeps saying:
  50.   k>     
  51.   k> " 
  52.   k> ccom: Error: tr.c, line 12: no automatic aggregate initialization
  53.   k>         int     ttime[6]={0,0,0,0,0,0};
  54.   k>       ------------------^
  55.   k> ccom: Error: tr.c, line 12: illegal lhs of assignment operator
  56.   k>         int     ttime[6]={0,0,0,0,0,0};
  57.   k>       ---------------------^
  58.     [ deletia ]
  59.   k> "
  60.  
  61.   k>    I really don't see what is wrong, the more because in my c-book,
  62.   k>    "C by discovery" by L.S. Foster on page 213, almost exactly the
  63.   k>    same thing is done.
  64.  
  65. Well, the problem (I am somewhat sure) is your compiler.  If I have
  66. the story right, this is not in the ANSII standard, and so
  67. "ANSII-compatible" compilers need not implement it.  The only solution
  68. I know of is to put it into a function called right off the bat or
  69. switch compilers.
  70.  
  71.  
  72.             ---- tomster@wpi.wpi.edu
  73.  
  74. --
  75. /****************************************************************************\
  76. | "I sometimes used to try to catch her, :    FROM:   tomster@wpi.wpi.edu  |
  77. | but never even caught her name."     :    TO:    who(m)ever reads it  |
  78. |    ---- the cure             :    CC:    programming language |
  79. \vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/
  80.