PDA

View Full Version : Help using open and write system calls in C !!!



vikkyhacks
July 23rd, 2012, 05:37 PM
void main()
{
write(open("a",1),"Hello",10);
}



My teacher taught me this program ... He told me that read and write are system calls used directly from the header. But he did not tell me what the second and third arguments of the open() and write() calls mean..... I searched the internet but there they tell me something like O_RDWD or O_RD (... something) which requires headers. Please explain me the second and third arguments used here with numbers....

MadCow108
July 23rd, 2012, 06:21 PM
see:
man 2 open
man 2 write

the section 2 in manpages are system calls (see http://linux.die.net/man/ for the other sections)

trent.josephsen
July 23rd, 2012, 06:34 PM
Your teacher sounds like a hack.