system("mkdir dir_name"); - will this command create a directory in the unix machine?
My first recommendation would be to try it, make sure it works on your system, but yes, that command worked for me to create a directory named 'dir_name' in my current directory.
But how do i write a file to that directory which i create?
Well, once again, my recommendation is to try it. I believe declaring an outstream and then writing to it will create the file, but if that doesn't work you can always use the 'system' command with the *nix 'touch filename' command to create it, and then open it from there (though I believe the first method would work).