Help us and donate little Bitcoins to pay the server costs: 1AXLPuRUBYc1JczTW4XS65GL6oWjNP2Vt2

User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

because of the inhumane working conditions at amazon in Germany, I will offer the Amazon app no more! (ARD Reportage)


#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
FILE * fopen (const char * restrict path, const char * restrict mode)

Opens file named restrict path and returns a stream, or NULL on failure. mode may be one of the following for files or one of those strings with b included (after the first character), for binary files.


Open a file
Arguments for mode are:
“r” Open a file for reading
“w” Create / writing
“a” Append
“b” Open a binary file
“rb” Open binary file for reading
”+” Open file for read/write
“r+” text update (reading and writing)
“w+” text update, discarding previous content (if any)
“a+” text append, reading, and writing at end
example fopen(“test.txt”, “r+”);, fopen(“test.txt”, “w+”); fopen(“test.txt”, “rw”); …

C Sourcecode Example

 * fopen example code
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
int main( void )
  FILE *handle;
  handle = fopen("test.txt","r");
  if ( handle != 0 )
    printf("fopen success:\n");
  } else {
         printf("fopen failure\n");
         if (handle != NULL) {
         return 1;
  return 0;

fopen output example

  output: if no test.txt file there
  user@host:~$ ./fopen 
  fopen failure
  output: if test.txt exist
  user@host:~$ ./fopen 
  fopen success
c/stdio.h/fopen.txt · Last modified: 2015/05/04 11:13 by

The new Question & Answer System is online and waiting for your Questions about Programming problems Impressum