# fopen() in C with directory



## ibo (Nov 2, 2007)

Alright, so in Linux, writing

```
FILE *fp = fopen("text","wb")
```
 will eventually be used to save a file named "text" in the directory where the executable is. What if I want to specify a relative or even an absolute directory. How would I be able to do it then?

FILE *fp = fopen("~/Desktop/folder/text","wb") does not work. // also...


----------



## ibo (Nov 2, 2007)

this works (the problem is ~)

```
fp=fopen("./folder/t", "wb")
```


----------

