create empty .txt file

Posted By: CodeMaster

create empty .txt file - 09/17/13 22:20

how create a empty .txt file in my working folder?
i can't find this function in the manual
Posted By: Uhrwerk

Re: create empty .txt file - 09/17/13 22:38

Code:
// returns non-zero on success, zero on failure.
fixed create_empty_file(STRING* fname)
{
   if (fname == NULL)
      return 0;

   fixed handle = file_open_write(fname);

   if (handle)
      file_close(handle);

   return handle;
}

Posted By: HellThunder

Re: create empty .txt file - 09/17/13 22:48

Hi!

Here is the link to the Manual. Yay it is a Little bit hidden.
http://www.conitec.net/beta/afile_open_read.htm

Code:
file_open_write (STRING* name);

or
Code:
file_open_append(STRING* name);


will do it.


But you can also use <stdio.h> for manipulate files.
Code:
FILE *document = fopen("FileName.txt", "w");


Here is a reference
http://www.cplusplus.com/reference/cstdio/
Posted By: CodeMaster

Re: create empty .txt file - 09/17/13 22:54

thanks to you i just noticed in manual if the file does not exist, it is created with file_open_write

thanks, problem is solved laugh
© 2024 lite-C Forums