- The C Standard Library
![Dev Dev](/uploads/1/2/6/5/126509837/790781930.jpeg)
Useful add-on libraries and tools for Dev-C and/or Mingw. Each package comes with a setup program to make installation easier. Documentation API references, guides, manuals, tutorials, etc. Available online or for download. Language Files Translate and maintain Dev-C Language files, or get language updates. Getting help.
Dev C++ Help File Download
- C Standard Library Resources
- C Programming Resources
- Selected Reading
Description
The C library function FILE *fopen(const char *filename, const char *mode) opens the filename pointed to, by filename using the given mode.
Declaration
Following is the declaration for fopen() function.
Dev C++ For Windows 10
Parameters
- filename − This is the C string containing the name of the file to be opened.
- mode − This is the C string containing a file access mode. It includes −
Sr.No. | Mode & Description |
---|---|
1 | 'r' Opens a file for reading. The file must exist. |
2 | 'w' Creates an empty file for writing. If a file with the same name already exists, its content is erased and the file is considered as a new empty file. |
3 | 'a' Appends to a file. Writing operations, append data at the end of the file. The file is created if it does not exist. |
4 | 'r+' Opens a file to update both reading and writing. The file must exist. |
5 | 'w+' Creates an empty file for both reading and writing. |
6 | 'a+' Opens a file for reading and appending. |
Return Value
This function returns a FILE pointer. Otherwise, NULL is returned and the global variable errno is set to indicate the error.
Example
Help Files Development
The following example shows the usage of fopen() function.
Let us compile and run the above program that will create a file file.txt with the following content −
Dev C++ Online
Now let us see the content of the above file using the following program −
Dev C Compiler
Let us compile and run the above program to produce the following result −
Originally released by Bloodshed Software, but abandoned in 2006, it has recently been forked by Orwell, including a choice of more recent compilers. It can be downloaded from:
http://orwelldevcpp.blogspot.com
Installation
Run the downloaded executable file, and follow its instructions. The default options are fine.Support for C++11
By default, support for the most recent version of C++ is not enabled. It shall be explicitly enabled by going to:Tools -> Compiler Options
Here, select the 'Settings' tab, and within it, the 'Code Generation' tab. There, in 'Language standard (-std)' select 'ISO C++ 11':
Ok that. You are now ready to compile C++11!
Compiling console applications
To compile and run simple console applications such as those used as examples in these tutorials it is enough with opening the file with Dev-C++ and hitF11
.As an example, try:
File -> New -> Source File
(or Ctrl+N
)There, write the following:
Then:
File -> Save As...
(or Ctrl+Alt+S
)And save it with some file name with a
.cpp
extension, such as example.cpp
.Now, hitting
F11
should compile and run the program.If you get an error on the type of
x
, the compiler does not understand the new meaning given to auto
since C++11. Please, make sure you downloaded the latest version as linked above, and that you enabled the compiler options to compile C++11 as described above.