~ is a notation that is expanded by your shell (e.g. Bash) into your home directory, so if you invoke a program like
vim ~/proj/viagens.txt, the shell will expand the parameter into
/home/ventura/proj/viagens.txt before the program
vim ever sees it.
~ is not understood by
fopen, which requires an absolute path path or a path relative to the current working directory.
(As @Osiris and @AndrewHenle point out in their comments,
fopen doesn't segfault, but it will return null when it can't find the file, which will cause a segfault down the line when you try to use
f as a file descriptor.)