![]() |
File Handling in C - File Pointers
On 2nd September, 2006
|
Recent Articles
Similar Articles
Code: C
Your program must open a file before it can access it. This is done using the fopen function, which returns the required file pointer. If the file cannot be opened for any reason then the value NULL will be returned. You will usually use fopen as follows Code: C
"r" => Open a file for reading "w" => Create a file for writing "a" => Open a file for appending Closing a file using fclose The fclose command can be used to disconnect a file pointer from a file. This is usually done so that the pointer can be used to access a different file. Systems have a limit on the number of files which can be open simultaneously, so it is a good idea to close a file when you have finished using it. This would be done using a statement like Code: C
Standard file pointers in UNIX UNIX systems provide three file descriptors which are automatically open to all C programs. These are stdin => The standard input.The keyboard or a redirected input file. stdout => The standard output.The screen or a redirected output file. stderr => The standard error.This is the screen, even when output is redirected. This is a conventional place to put any error messages. Since these files are already open, there is no need to use fopen on them. |
|
|
#2 |
|
Ambitious contributor
Join Date: Feb 2008
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2 ![]() |
Re: File Handling in C - File Pointers
thanks a lot , file handling is realyy tough forme
|
|
|
|
|
|
#3 |
|
Newbie Member
Join Date: Oct 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: File Handling in C - File Pointers
if you explain other file related functions in ths thread means it will be very nice....
|
|
|
|
![]() |
|
| Currently Active Users Reading This Article: 1 (0 members and 1 guests) | |
| Article Tools | Search this Article |
| Display Modes | |
| Bookmarks | |
|
|
|
||||||||||||||||||||||||||||||||