[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
Zeev Suraski » CppReturn » CppSeagull » compression » midlet » CLinkingError » CppConstructor » PCI-X » WirelessToolKit » CompareCppBuilderWithDelphi » CFopen

(C) fopen

'File Open', a function used in file I/O.

Example

  1. include <stdio.h>
  2. include <assert.h>
int main(void) { FILE * pFile = 0; char myText[100]; /* Open the file myFile.txt for writing */ pFile = fopen ("myFile.txt","w"); /* Assume file has been opened succesfully */ assert(pFile != 0); /* Prompt for input */ puts("please type some text:"); /* Get the input in the character buffer 'myText'*/ gets(myText); /* Write character buffer 'myText' to file */ fprintf (pFile, "Your text: %s\n",myText); /* Close the file */ fclose (pFile); return 0; }


The options of fopen are:
+----+------------------------------------------------------+
| r  | open for reading                                     |
| w  | open for writing (file need not exist)               |
| a  | open for appending (file need not exist)             |
| r+ | open for reading and writing, start at beginning     |
| w+ | open for reading and writing (overwrite file)        |
| a+ | open for reading and writing (append if file exists) |
+----+------------------------------------------------------+


'fopen' links

Code links



last edited (December 20, 2006) by bilderbikkel, Number of views: 3502, Current Rev: 3 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Site Management by Lars Hagelin at Kontantkort.se.