关于#c语言#的问题:c语言编写程序,完成如下功能:提示用户输入文件名,使用该文件名创建文件

c语言编写程序,完成如下功能:提示用户输入文件名,使用该文件名创建文件,并将其存入d盘

#include <stdio.h>
#include <string.h>

int main() {
    char filename[50];
    FILE *fileptr;

    printf("Enter the file name: ");
    scanf("%s", filename);
    char filepath[100] = "D:\\";
    strcat(filepath, filename);
    fileptr = fopen(filepath, "w");
    if (fileptr == NULL) {
        printf("Error creating file\n");
        return 1;
    }
    fclose(fileptr);
    return 0;
}