-1
#include <stdio.h>
int main (){
    char nome_arq[20];
    printf("Digite o nome do arquivo: ");
    scanf("%s",&nome_arq);
    FILE *file;
    file=fopen("-------.txt","w");
    fprintf(file,"huahuahuahuauh");
    fclose(file);
return 0;
}
						-1
#include <stdio.h>
int main (){
    char nome_arq[20];
    printf("Digite o nome do arquivo: ");
    scanf("%s",&nome_arq);
    FILE *file;
    file=fopen("-------.txt","w");
    fprintf(file,"huahuahuahuauh");
    fclose(file);
return 0;
}
						2
Having the #include <string.h> you can use the strcat(str1, str2) function to concatenate 'strings', leaving your logic more or less like this:
file=fopen(strcat(nome_arq, ".txt"),"w");
							Browser other questions tagged c
You are not signed in. Login or sign up in order to post.