[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CFileIo

(C) File input/output

The reading from and writing to a file. Aften abbreviated to 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; }


Questions

  • What are the options on opening a file I want to read from?
  • What are the options on opening a file I want to write to ?
  •  ?How can I check if a file exists?
  •  ?How do I copy a file?
  •  ?How do I get a file's path?
  •  ?How do I get a filename's extension?
  •  ?How do I remove a filename's extension?

'File I/O' links

Code links



last edited (June 12, 2007) by bilderbikkel, Number of views: 1714, Current Rev: 5 (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. Development by Tore Nestenius at .NET Consultant - Synchron Data.