# File management

For accessing files, we shall use `FILE`  structure in the following way,

```c
#include <stdio.h>

int main()
{
    FILE* fp;
    fp = fopen("file.txt", "w");
    fclose(fp);
    return 0;
}

```

Here, `fopen("file_path", "mode");`

`for modes,`

```markdown
a = append (creates file if not present)
w = write (creates file if not present)
a = read (error if not present)
```

***

Here, `fclose(fp)` is optional!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sharafat.gitbook.io/c/intermidiate/file-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
