[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CFileIo
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CFileIo
(C) File input/output
The reading from and writing to a file. Aften abbreviated to File I/O.Example
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; }
- include <stdio.h>
- include <assert.h>
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
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
