🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.dec
Article #346

Need to know how to fflush(stdin) in VMS C.

#346
From: Issa El-Hazin
Date: Wed, 08 Apr 1992 20:23
49 lines
2449 bytes
Does anybody know how to flush the stdin in VMS 'C'? I'm using the system();
function to run a command and would like to flush any key(s) the user might
press while waiting for the command to complete (esp. since the system(); call
takes a long time to spawn and run if there are too many people on the system
(Is there a faster alternative to using the system() call? I'm using VMS 5.4.3)
Also if anybody knows how to disable the Ctrl-Y  from within a 'C' program I 
would be greatly appreciative. I'm modifying a VMS menu program (5000 lines) 
that I've wrote and if anybody is interested in running it they can do so by 
telneting to zeus.unomaha.edu and login as a guest then typing "window" at 
the $. The program is located in perm$5:[conslt24.public]. Please feel free 
to use or to get a copy of it. Back to my question I'm doing something similar 
to the next program and I can't figure out why it's not working.


#include <stdio.h>

main()
{

char test;
int array[10];

	printf("\n Type a letter: ");
	scanf("%c",&test);	/* wait until I'm ready		      */

	sleep(5);		/* while waiting for 5 seconds        */
				/* Type a string and press <enter>    */

	fflush(stdin);		/* flush standard input (keyboard)   */

	scanf("%s",&array);	/* read what's in the input buffer    */

	printf("\n%s",array);	/* will print the string typed before */
				/* flushing the stdin		      */
}


Any suggestions are welcomed and are greatly appreciated.

Thanks in advance

/-Issa-/

(P.S. I'm not using scanf() to read the input, instead I'm using a function
      called keypress() which will grap a char pressed without having to press
      the enter key (arrow keys, F? keys ..), but I've tried the above program
      both ways and it still don't work. I know RMS has its own buffers but
      I can't find an example on how to do my requested task. fflush is 
      returning a '0' which indicates that the operation is successful)
Technical Details
Message-ID: <1992Apr8.202310.11007@news.unomaha.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!unlinfo.unl.edu!news.unomaha.edu!news

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.dec
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!unlinfo.unl.edu!news.unomaha.edu!news
From: CONSLT24@Zeus.unomaha.edu (Issa El-Hazin)
Subject: Need to know how to fflush(stdin) in VMS C.
Message-ID: <1992Apr8.202310.11007@news.unomaha.edu>
Sender: news@news.unomaha.edu (UNO Network News Server)
Organization: University of Nebraska at Omaha
Date: Wed, 8 Apr 1992 20:23:10 GMT
X-News-Reader: VMS NEWS 1.11
Lines: 49