From: Jon DeMarks Newsgroups: comp.os.msdos.djgpp Subject: Re: Terminal Programming Date: Sat, 24 Jul 1999 11:28:31 -0400 Organization: Tachyeon Systems Lines: 28 Message-ID: <3799DB9E.385E4ECD@mindspring.com> References: <3798FE1B DOT AE7EEEC AT mindspring DOT com> <7nbre4$am$1 AT news DOT luth DOT se> NNTP-Posting-Host: d1.8a.0e.9d Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 24 Jul 1999 15:28:09 GMT X-Mailer: Mozilla 4.04 [en] (Win95; U) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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 > : 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.