try using the 'chdir' command to change directories. the problem with using system("cd"), is that the 'cd' command only affects the current process executing it. after that process terminates, the current working directory is reset to that of the parent process. in the case of using system(), this actually creates a new process to execute the command. so, system creates a new process, sets the current directory for that one, and then terminates; leaving the parent process still in the same directory.
i read ur assign, you are supposed to be making classes for each of those recat/attrcat. then you would instantiate objects of each one. to write to a file, use a binary writing method, like fread() and fwrite(). try and write some code and see where u get.