Here :
Code:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#define HISTORY_SIZE 10
#define MAX_STRING_LEN 100
#define MAX_CMD_LEN 10
void printHistory( char history[][MAX_CMD_LEN], int size);
int processCommand( char *current, char *cmd, char *result);
void updateHistory( char history[][MAX_CMD_LEN], const char *cmd, int size)={0};
int main(void)
{
int i;
char cmd[MAX_CMD_LEN]="";
char current[MAX_STRING_LEN]="";
char result[MAX_STRING_LEN]="";
char history_table[HISTORY_SIZE][MAX_CMD_LEN]={};
int history_size = 0;
int flag;
printf("Enter command [help] for a list of commands\n");
do {
printf("cmd> ");
fflush(stdout)
gets(cmd); //get a command from user.
if(strcmp( cmd, "hist") == 0) {
printHistory( history_table, history_size);
}
else {
flag= processCommand(current, cmd, result);
}
if( cmd !="")
{
updateHistory(history_table, cmd, history_size);
history_size++;
}
}while (flag!=1);
return 0;
}
void updateHistory( char history[][10], const char *cmd, int size)
{
ctrcpy(history[size],cmd);
}
void printHistory( char history[][MAX_CMD_LEN], int size)
{
int i,j;
printf("Size of history: %d\n", size);
for( i=0; i<size; i++)
{
puts(history[i]);
printf("\t");
}
}
won't compile
Code:
'ctrcpy': identifier not found