|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Is difference lies in the fact that fopen part of c library and
platform in-depended, whereas open is a system call? what about functionalities? thx |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
In comp.lang.c, magicman wrote:
> Is difference lies in the fact that fopen part of c library and > platform in-depended, whereas open is a system call? what about > functionalities? With respect to the C standard, fopen() is defined by the standard, takes specific arguments, performs a specific function, and returns specific results, while open() is *not* defined (or even recognized) by the standard. fopen() is guaranteed to be part of the standard I/O library in a hosted environment, while open() is left available as any sort of user function. In /some environments/, open() is an environment-specific function that provides low-level ("system") access to specific I/O functions. However, there is no guarantee (from the C language pov) of what open() does, what arguments it takes or what it returns, and it is perfectly legal for an application program to include a function called open() with it's own code. -- Lew Pitcher Master Codewright & JOAT-in-training | Registered Linux User #112576 http://pitcher.digitalfreehold.ca/ | GPG public key available by request ---------- Slackware - Because I know what I'm doing. ------ |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
magicman wrote:
> Is difference lies in the fact that fopen part of c library and > platform in-depended, whereas open is a system call? Basically yes. > what about functionalities? Which also unsurprisingly differ. Generally open is more flexible than fopen. It allows you to specify various status values for the file and returns error codes, which fopen is not guaranteed to do. See man 3 open and man 2 open. The actual system call is wrapped by a user-space function, both with identical names. To further discuss open <news:comp.unix.programmer> should be more appropriate. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
In article <199b3caa-f6fc-4755-bf49-698a6c4aaa16@m45g2000hsb.googlegroups.com>,
magicman <ironsel2000@gmail.com> wrote: >Is difference lies in the fact that fopen part of c library and >platform in-depended, whereas open is a system call? what about >functionalities? open() is the Unix system call for opening files. The fact that it's a system call rather than some other kind library function isn't very important to users; but it corresponds to the fact that in Unix it's the basic file opening method. Some other operating systems have a similar function, but as C comes from the world of Unix you probably mean that one. fopen() is the standard C function for opening files. A Unix implementation will use open() in the implementation of fopen(), but the stream returned by fopen() provides buffering and works with functions like printf(). Unless you want to take advantage of system-specific features, stick with fopen(). -- Richard -- :wq |
|
![]() |
| Outils de la discussion | |
|
|