Mail Archives: djgpp/1999/07/30/15:38:46
Martin Str|mberg wrote:
> Jon DeMarks (whatfor AT mindspring DOT com) wrote:
> : I am trying to write a terminal that will get a command typed by the
> : user and execute a function corresponding to it. Any suggestions? The
> : following code snippet is stand-alone and can be compiled.
> : #include <stdio.h>
> : void _freedbgkern() { char buf[128];
> : printf("\nFreedows Terminal v.1.0a By Jon DeMarks\n\n");
> : for(;;) { fflush(stdin); scanf("%s", buf);
> ^^^^^^^^^^^^^
> : if(buf=="sd") { sd(); }
> : else { printf("Invaild command %s, come again?\n", buf); } } }
>
> fflush(stdin) results in undefined behaviour. Don't do that.
>
> (Another minor observation is that it compilable, but not linkable
> (and thus not runable) (sd() undefined).)
>
> Kokkonen, Symphony No. 4,
>
> MartinS
you have to rename the fuction to main() to compile. and the
fflush(stdin); doesn't make a differance.
- Raw text -