Lab 2 for DS + Algorithms FileTest contains a code snipit that contains a parser for handling the necessary commands.
A word of warning for any current student that stumbles across this, do NOT copy or cheat! You are only hurting yourself, as this lab may not be up to the professional grade level. Also, by copying someone elses code you do not get the sense of achievement from the discovery, understanding and personal satisfaction that is only achieved through working through the problem.