i have an array of type char
char *arg[100]
this array its reading the data from somewhere, when that when i print arg[0]
, it prints the value "help", and when i print the arg[1]
, it prints the value "exit".. as an example
what i want exactly is to change the arg[0]
from "help" to anything else, like "man"
how i can do that???
thank you
the code:
int executeCommands(char arg31[])
{
pid_t pid;
int status,number;
char *arg3[10];
//char str2[21];
x = 0;
arg3[x] = strtok(arg31, " \n\t");//this line to tokenize every commands and its arguments from the passed array of chars (which is the command)
while(arg3[x])
arg3[++x] = strtok(NULL, " \n\t");
if(NULL!=arg3[0])
{
if(strcasecmp(arg3[0],"cat")==0) //done
{
int f=0,n;
char l[1];
struct stat s;
if(x!=2)
{
printf("Mismatch argument\n");
return 0;
}
else if(strcmp(arg3[0],"help")==0) // done
{
if (strcmp(arg3[1],"cat")==0)
printf("1");
else if(strcmp(arg3[1],"rm")==0)
printf("1");
else if(strcmp(arg3[1],"rmdir")==0)
printf("1");
else if(strcmp(arg3[1],"ls")==0)
printf("1");
else if(strcmp(arg3[1],"cp")==0)
printf("1");
else if(strcmp(arg3[1],"mv")==0)
printf("1");
else if(strcmp(arg3[1],"hi")==0)
printf("1");
else if(strcmp(arg3[1],"exit1")==0)
printf("1");
else if(strcmp(arg3[1],"sleep")==0)
printf("1");
else if(strcmp(arg3[1],"history")==0)
printf("1");
else if(strcmp(arg3[1],"type")==0)
printf("1");
else
{ char manarg[] = "man\t";
arg3[0] = strtok(manarg, " \n\t");
executeCommands(arg3);
}
writeHistory(arg3);
}