The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script required to get a required info from file. Pls. help me. ntgobinath Shell Programming and Scripting 2 05-31-2008 09:34 AM
Help required on awk meetavin Shell Programming and Scripting 3 04-18-2008 10:47 AM
SSL help required binums HP-UX 0 05-04-2006 03:03 AM
Help required on DBX Sumanth SUN Solaris 1 07-29-2004 10:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-03-2003
ruffenator ruffenator is offline
Registered User
  
 

Join Date: Jan 2002
Location: uk
Posts: 23
help required

hi i am new to c programming and found this on the net could someone tell me what it actually does, many thanks in advance cheers


#include <fcntl.h>
main()
{
int fd;

fd = open("in1", O_RDONLY);
printf("%d\n", fd);
}

and this too please



#include <fcntl.h>
main()
{
int fd;

fd = open("in1", O_WRONLY);
if(fd < 0)
{
perror("filename");
exit(1);
}

}
  #2 (permalink)  
Old 02-03-2003
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
First one: open file "in1" read-only and print out the file descriptor (file handle)
Second: open file "in1" write-only and if open() returns a negative number (like -1) that means it cannot be open()ed. Show error message and quit.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0