Question: #include HALmod.h int main(){ string tokens [MAX_COMMAND_LINE_ARGUMENTS]; int tokenCount; do{ tokenCount = GetCommand (tokens); } while (ProcessCommand (tokens, tokenCount)); return 0; } HALmod.h #include #include

#include "HALmod.h"

int main(){

string tokens [MAX_COMMAND_LINE_ARGUMENTS];

int tokenCount;

do{

tokenCount = GetCommand (tokens);

} while (ProcessCommand (tokens, tokenCount));

return 0;

}

HALmod.h

#include

#include

#include

#include

#include

#include

using namespace std;

//The following two lines come from HALglobals.h

const int MAX_COMMAND_LINE_ARGUMENTS = 8;

const int SLEEP_DELAY = 100000;

int GetCommand (string tokens []);

int TokenizeCommandLine (string tokens [], string commandLine);

bool CheckForCommand ();

int ProcessCommand (string tokens [], int tokenCount);

static volatile sig_atomic_t cullProcess = 0;

int GetCommand (string tokens [])

{

string commandLine;

bool commandEntered;

int tokenCount;

do

{

cout << "HALshell> ";

while (1)

{

getline (cin, commandLine);

commandEntered = CheckForCommand ();

if (commandEntered)

{

break;

}

}

} while (commandLine.length () == 0);

tokenCount = TokenizeCommandLine (tokens, commandLine);

return tokenCount;

}

int ProcessCommand (string tokens [], int tokenCount)

{

if (tokens [0] == "shutdown" || tokens [0] == "restart")

{

if (tokenCount > 1)

{

cout << "HALshell: " << tokens [0] << " does not require any arguments" << endl;

return 1;

}

cout << endl;

cout << "HALshell: terminating ..." << endl;

return 0;

}

else

return 1;

}

  1. What is this code's tokenizing based on (ie. what delimeter(s) separate(s) the words)?
  2. What are two reasons why the tokens are strings instead of c strings

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!