Server for Information Technologies ������ ��������������
������� �������������� ����������
(095) 932-9212, 932-9213, 939-0783
E-mail: [email protected]
������ �������� ����(!) ������������� ���������� CIT Forum CD-ROM

FOPEN(3S)

��������
fopen, freopen, fdopen - ������� �����

���������

	#include <stdio.h>
	
	FILE *fopen (filename, type)
	char *filename, *type;
	
	FILE *freopen (filename, type, stream)
	char *filename, *type;
	FILE *stream;
	
	FILE *fdopen (fildes, type)
	int fildes;
	char *type;

��������
������� fopen ��������� ���� � ������ filename, ����������� � ��� ����� � ���������� ��������� �� ��������� ���� FILE, ��������������� ����� ������.

�������� filename �������� ���������� �� ������� �������� - ��� ������������ �����.

�������� type - ��� ��������� �� ������� ��������, ������� ����� ��������� ���� �� ��������� ��������:
r ������� �� ������.
w ���������� ��� ������� ��� ������.
a ���������; ������� ��� ������ � ����� ����� ��� ������� ��� ������.
r+ ������� ��� ��������� (������ � ������).
w+ ���������� ��� ������� ��� ���������.
a+ ���������; ������� ��� ������� ��� ��������� � ����� �����.

������� freopen ����������� ��������� ���� ������ ����� ��������� ������, ��������� ���������� stream. �������������� ����� ����������� ���������� �� ����, ������� �� ������� ����� ����. ������� freopen ���������� ��������� �� ��������� ���� FILE, ��������������� � �������.

������� freopen ������ ������������ ��� �������� ������� �������� ������� stdin, stdout � stderr � ������ ������.

������� fdopen ����������� ����� � ������������ ����� fildes, ���������� � ���������� ���������� ��������� ������� open, dup, creat ��� pipe(2), ������� ��������� ����, �� �� ���������� ��������� �� ��������� ���� FILE, ����������� �����. ���� ��������� ��������� ��� ������������� ������ �� ������ ������������ �������� ���������� 3S. ��� ������, �������� ���������� type, ������ ��������������� ������ ������� � ��������� �����.

���� ���� ����������� ��� ����������, �� � ��������������� ������ ��������� �������� ��� �����, ��� � ������. ������ �������� ����� �� ����� ��������������� ��������� �� ��������� ������, ��� �������������� ������������� ������� fseek ��� rewind, � �������� ������ �� ����� ��������������� ��������� �� ��������� ����� ��� �������������� ������������� ������� fseek, rewind ��� �������� �����, ����������� ����� �����.

���� ���� ����������� ��� ���������� (�� ���� ��� type ����� "a" ��� "a+"), �� ���������� �������� ����������, ��� ������������ � �����. ������� fseek ����� �������������� ��� ����������� ��������� ����� � ����� ��� �������, �� ��� �������� ������ ��������� ������� ������� ����� ������������. ��� ��������� ���������� ������������ � ����� ����� � ��������� ������� ������� ������������ �� ����� ������������ ������. ���� ��� �������� ��������� ���� � ��� �� ���� ��� ����������, �� ������ ������� ����� ������ � ���� ��� ����� ��������� ����� ������� ��������. ������, ������������ ����� ����������, ����� ������������ � ����� � ������� �� �����������.

��. �����
creat(2), dup(2), open(2), pipe(2), fclose(3S), fseek(3S), stdio(3S).

�����������
� ������ ������ ������� fopen, fdopen � freopen ���������� ������ ��������� NULL.
Comments: [email protected]
Designed by Andrey Novikov
Copyright © CIT