#include #include #define ARGVMAX 100 #define LINESIZE 1024 int makeargv(char *s, char* argv[ARGVMAX]) { // in: s points a text string with words // out: argv[] points to all words in the string s (*s is modified!) // pre: argv is predefined as char *argv[ARGVMAX] // return: number of words pointed to by the elements in argv (or -1 in case of error) int ntokens; if ( s==NULL || argv==NULL || ARGVMAX==0) return -1; ntokens = 0; argv[ntokens]=strtok(s, " \t\n"); while ( (argv[ntokens]!= NULL) && (ntokens "); fflush(stdout); //writes the prompt on the standard output while ( fgets( line, LINESIZE, stdin ) != NULL ) { if ( makeargv( line, av) > 0 ) runcommand( av ); printf("> "); fflush(stdout); } return 0; }