From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: questions Date: Sat, 09 May 1998 21:29:14 -0400 Organization: Two pounds of chaos and a pinch of salt. Lines: 82 Message-ID: <355502EA.1B14@cs.com> References: <6j2u57$alk AT nnrp3 DOT farm DOT idt DOT net> NNTP-Posting-Host: ppp119.cs.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk My apologies for the previous incomplete post. Thomas Beauchamp wrote: > > Could somebody please help me by sending me a small example program of > conio.h input/output functions? I know that you're all thinking that > I'm an idiot, but I would really appreciate the help. For information on conio functions, read the libc docs ("info libc func conio"). #include #include /* kbhit */ #include /* toupper */ #include /* delay */ void clear_key_buffer( void ) { while ( kbhit() ) getch(); } int main( void ) { struct text_info ti; char line[100]; float f; int i, x; char c; gettextinfo( &ti ); /* save previous screen state */ clrscr(); /* clears screen */ cprintf( "Please type a word: " ); cscanf( "%s", line ); cprintf( "\n\rYou typed '%s'.\n\r", line ); cputs( "Please type a complete line:\n\r" ); line[0] = 100; /* size of buffer */ line[1] = 0; /* length of string */ clear_key_buffer(); /* cscanf leaves \n\r in buffer */ cgets( line ); cputs( "\n\rYou typed:\n\r" ); for ( i = 0; i < line[1]; i++ ) putch( line[i + 2] ); /* string starts at third element */ cprintf( "\n\rPlease type a float followed by an integer: " ); if ( cscanf( "%f%d", &f, &x ) < 2 ) cputs( "\n\rYou typed an invalid character.\n\r" ); else cprintf( "\n\rYou entered %f and %d.\n\r", f, x ); clear_key_buffer(); cputs( "Type some characters, one at a time. Press Q to stop.\n\r" ); for ( c = ' '; toupper( c ) != 'Q'; ) c = getch( ); cputs( "Now try again.\n\r" ); for ( c = ' '; toupper( c ) != 'Q'; ) c = getche( ); cputs( "\n\rPress any key for color test..." ); getch( ); cputs( "\n\r" ); for ( i = 0; i < 256; i++ ) { textattr( i ); cprintf( "fg = %3d bg = %3d blink = %d\n\r", i & 0xf, ( i >> 4 ) & 0x7, i >> 7 ); delay( 100 ); } textattr( ti.normattr ); cputs( "This has been a test of your basic conio functions.\n\r" ); cputs( "Have a nice day.\n\r" ); return 0; } Good luck! -- --------------------------------------------------------------------- | John M. Aldrich |"Men rarely (if ever) manage to dream | | aka Fighteer I |up a god superior to themselves. Most | | mailto:fighteer AT cs DOT com |gods have the manners and morals of a | | http://www.cs.com/fighteer |spoiled child." - Lazarus Long | ---------------------------------------------------------------------