More getch() woes

Alan Sparks sparks at power.viewlogic.com
Tue Mar 26 00:55:17 AEST 1991


In article <669422030.1 at opocus.Fidonet.Org> you write:
>Marc WANDSCHNEIDER writes to All: 
>
> The following program WITHOUT The line #include <conio.h> does not 
> work.  It just freezes the entire system up, and I have to reboot (usin TC++  
>
> #include <stdio.h>
> #include <conio.h>
>
> main()
> {
>    int i, test, c[25];
>
>    i = 0;
>    c = 0;
     ^^^^^^
THIS LINE SHOULD NOT COMPILE!

>
>    while ((i < 25) || (test !='A')) {
> 	   test = getch();
> 	   c[i++] = test;
> 	   }
>    printf("\n\n   %s", c);
>    return 0;
> }
>
> Any insight...?
>
>--------------------------------
>I get the same result (Lvalue required) with or without includeing conio.h.  
> 
>
> * Origin: Point No Point (Lebanon, IN) (1:231/270.3)


If your compiler let you do the above marked line, it's a bit brain-
damaged... the standard (either one) does not sanction assignment to
arrays.  Initialization of c[] here should be do with a for loop.

-Alan
-- 

Alan Sparks      voice: (508) 480-0881  Internet: sparks at viewlogic.com
VIEWlogic Systems Inc., 293 Boston Post Rd. W., Marlboro MA 01752
Disclaimer: VIEWlogic didn't say this; I might have.  Who's asking?



More information about the Comp.lang.c mailing list