char buf[500]; sprintf (buf,"./%s",fname); //hope buf is large enough to hold string without overflowing cause there ain't a lot of out-of-bounds checking here The open system call takes three arguments: the file name, the flags, and the file modes should a file be created. open flags: O_RDONLY read only O_WRONLY write only O_RDWR read & write O_CREAT create file if it doesn't eixt O_EXCL prevent creation it already exists O_APPEND writes new information to the end of the file for reading: fd = open ("fname.txt",O_RDONLY); for writing: fd = open ("fname,txt",O_WRONLY | O_CREAT, 0644) or maybe 0700 0644 = user-rw, group-r, world-r. = user-rwx, group-nothing, world-nothing Anytime O_CREAT appears as a flag for open, a file mode parameter must be given. In the C-language, any integer beginning with a leading 0 is treated as octal. So, in C, 12 and 012 are not the same number. 12 is 12, but 012 is ten. In the C language, any integer beginning with 0x is treated as hexadecimal. 0xff is 255. File permission bits: user read write execute 400 200 100 Group 40 20 10 World 4 2 1 If I want to give myself read/write access and everyone else read access, that is 0644. If it's a program, the typical mode is 0755. Me, personally, I tend to give my files 0700. I get everything. screw everyone else. Read on a directory allows someone to get a look at the file list. Write on a directory allows someone to add or delete from the directory. Execute on a directory allows someone to use that directory at all! (Use it in a pathname). On a linux system, the root has read/write to everything, no matter what the file permissions are. There are three special permissions as well: set-user-id 4000 set-group-id 2000 sticky bit 1000 set-user-id (and also set-group-id) is DANGEROUS. Be very careful with this one. set-user-id on an executable program, changes your userid to the owner of the program during its execution. set-group-id on an executable changes your groupid to the group of the program during its execution.