Hi there, its me again... Now i know you are very anti do our homework for us, i understand this, and wholeheartedly agree, however, i need help with my homework.
The long and short of it, is this program is designed to act as a short directory of help commands used within unix, the code below isn't complete, but where bits are missing there are labels and it compiles with no errors.
Code:
/*
/* Interactive help system to train users into unix, using searches within strings and functions and all of it*/
/*mitchell kent, 323786*/
#include <stdio.h>
#include <string.h>
char command[6][5]={{"ls"},{"cd"},{"mv"},{"cp"},{"rm"},{"more"}};
char description[6][42]={{"list files in a directory"},{"change directory"},{"rename or move files to another directory"},{"copy files"},{"delete files"},{"display the contents of files"}};
/*this function searches for an inputted command and prints out the assc. description*/
int lookup(void)
{
int loop;
char comparison[5];
printf("Please enter command to look up");
printf("\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n");
scanf("%s",comparison);
printf("%s",comparison);
/* *******HERE IS THE PROBLEM****** */
for(loop=0;loop<=5;loop++)
{
if (comparison==command[loop])
{
printf("\nyour command was found:\n");
printf("%s - %s",command[loop],description[loop]);
}
}
/* *** *** *** *** *** *** *** *** */
return 1;
}
/*this prog will find words within the description and print out all commands with that word in*/
int findWID(void)
{
return 1;
}
/*this function will display the list of commands available for this help system*/
int disp_all_commands(void)
{
int loop;
for(loop=0;loop<=5;loop++)
{
printf("%s",command[loop]);
printf("\n");
}
return 1;
}
/*this function prints out all commands and their descriptions*/
int disp_all(void)
{
int loop;
for(loop=0;loop<=5;loop++)
{
printf("%s - %s",command[loop],description[loop]);
printf("\n");
}
return 1;
}
/*this main function will be a simple switch clause, to choose the required function*/
int main(void)
{
printf("Welcome to the UNIX help system:\n");
printf("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n");
disp_all();
printf("--------------------\n\n\n\n");
disp_all_commands();
printf("--------------------\n\n\n\n");
lookup(); /* the function in question*/
return 0;
}
*/
basically, the function in question (up the top, lookup() ) as far as i know should work. though i think there is a function that compares strings in the string header file. i get no errors but the if statement found below
Code:
/*
for(loop=0;loop<=5;loop++)
{
if (comparison==command[loop])
{
printf("\nyour command was found:\n");
printf("%s - %s",command[loop],description[loop]);
}
}
*/
should work, right?
any help?
cheers
Mitch