implemenation of cwd()

i'm writing my own shell and implementing a few unix commands.
I'm using the readline() for input and strtk() to tokenize it. I need to implement the cwd command as an option in the shell..
Here's the layout :

while true do
Read a line of input using readline()
tokenize the input
switch token[0] do
case cd
change to specified directory in token[1]
end
case pwd
print the current working directory
end
.....and so on

My C skills are a bit rusty...could use all the help i can get
Thanks in advance

chdir() changes directory

fgets(<string>, <size in bytes>, stdin) reads a line from the terminal - one way of many ways to do this - there is no readline in ANSI C

getcwd() gives you the current directory you are in