This shows you the differences between two versions of the page.
c:keywords:file [2013/01/22 22:02] 127.0.0.1 external edit |
c:keywords:file [2024/02/16 01:05] (current) |
||
---|---|---|---|
Line 3: | Line 3: | ||
FILE Pointer (stream) | FILE Pointer (stream) | ||
shows on a given file | shows on a given file | ||
- | // here is a better explanation necessary | + | |
+ | The data type FILE is a structure that contains information about a file | ||
+ | or specified data stream. It includes such information as a file descriptor, | ||
+ | current position, status flags, and more. It is most often used as a pointer | ||
+ | to a file type, as file I/O functions predominantly take pointers as | ||
+ | parameters, not the structures themselves (see example below). | ||
===== C Sourcecode Example ===== | ===== C Sourcecode Example ===== | ||
<code c> | <code c> | ||
Line 10: | Line 15: | ||
- | int main ( void ) | + | int main (void) |
{ | { | ||
- | FILE *filestream; | + | FILE *filestream; |
- | filestream=fopen("test.txt","r"); | + | filestream=fopen("test.txt","r"); |
- | if (filestream == 0) { | + | if (filestream == NULL) |
- | perror("cannot open file"); | + | perror("cannot open file"); |
- | } | + | |
- | + | ||
- | fclose(filestream); | + | |
- | return 0; | + | |
+ | fclose(filestream); | ||
+ | return 0; | ||
} | } | ||
</code> | </code> |