Creating a blank file in C

Hello,

How do I create a blank bat file in C? I need to create a blank bat file to write to it later in the program.

Thanks!

John


Comments

  • : Hello,
    :
    : How do I create a blank bat file in C? I need to create a blank bat file to write to it later in the program.
    :
    : Thanks!
    :
    : John
    :

    Mmmm, I don't now if you mean the following but it's an idea.

    You can use the functions fopen() and fclose() to open and close files with C. The function fprintf() can be used to write to a file.

    When the function fopen() is called a filehandle is created and this filehandle can be used to write to a file, the created file is empty, so a blank bat file or any other file.

    Else check for more info from your IDE (integrated developer environment).

    Goodluck Mark



  • Do this:

    FILE *empty_file = fopen("myfile.txt","w");
    fclose(empty_file);

    Now the file "myfile.txt" is created and is empty.


  • Once again, you guys fixed my problem. I would like to thank both of you. Happy holidays.

    John

    : Do this:
    :
    : FILE *empty_file = fopen("myfile.txt","w");
    : fclose(empty_file);
    :
    : Now the file "myfile.txt" is created and is empty.
    :



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories