Hello. I am new to this forum and hoping to find an answer to my problem. My lecturer at college is not quite doing what he is supposed to, and doesn't want to explain to us what certain commands do. My first question is What does strcmp() and strtok() do, and what's the right way to use them.

Then he asked us to write a C code to simulate the Command Prompt console that we can get in windows. Started off with an easy (i thought) one. Here is the code that I have, but it is not doing what I want it to do. It should be working like the "dir" command in cmd:

Code:
#include <stdio.h>#include <stdlib.h>
#include <dirent.h>


void cmdcom(char);
int main()
{
    char* cmdline;
    printf("C:\\ ");
    gets(cmdline);


    char* cmd;
    char* para1;
    char* para2;


    cmd=strtok(cmdline,"");
    para1=strtok();
    para2=strtok();






    if(strcmp(cmd,"CD")==0)
    {
        //CD command
    }
    if(strcmp(cmd,"dir")==0)
    {
        cmdcom(cmd);
    }
    return 0;
}
void cmdcom(char dirname)
{
    DIR *dir;
    struct dirent *ent;


        dir = opendir(dirname);


            if(dir!=NULL)
        {
        while ((ent=readdir(dir))!=NULL)
        {
            printf("%s\n",ent->d_name);
        }
        closedir(dir);
    }
    else
    {
        perror("");
    }
}
I am problably using strtok wrong, so any feedback is really appreciated. Also hints as to how to tackle a CD command, would be useful.

Regards,
Artur.