Skip to content
Sign upLog in
← Back to Community

C How to Create File and What Is Its Path?

Profile icon
emurray2

How do you create a file in C on repl.it and what is its path?

Voters
Profile icon
Harish-SIT5019S
Profile icon
emurray2
Comments
hotnewtop
Profile icon
Highwayman

FILE *file = fopen(path,mode); where path is the path to the file (already existent or not), and mode is the way in which you open the file( "r" for reading, "w" for writing, stuff like that)

This page has a couple of the open modes: http://cplusplus.com/reference/cstdio/fopen/?kw=fopen

Edit: also use w for creating a file.