Here's one way to do it. You'll need to replace _getche( ), with the borland equivalent. The function gets a character and echoes the character to stdout.
Code:
#include "stdafx.h"
#include<iostream>
using namespace std;
#include <conio.h>
#define NUMBER_OF_WORDS 20
char szWord[NUMBER_OF_WORDS][81] = {0};
enum status
{
eol,
more
};
status GetCommand( char * pszWords );
int main(void)
{
for( int i = 0; 1; i++ )
{
if( eol == GetCommand( &szWord[i][0] ) )
break;
}
cout << "done " << endl;
return 1;
}
status GetCommand( char * pszWords )
{
if( NULL == pszWords )
return eol;
status st = more;
char ch;
for( int i = 0; '\r' != ch && ' ' != ch; i++ )
{
ch = _getche( );
switch( ch )
{
case ' ':
break;
case '\r':
cout << endl;
st = eol;
break;
default :
*( pszWords + i ) = ch;
break;
}
}
return st;
}