I need to create a function that prompts the user to enter a string and use that string to create a file to which I will store data
this runs, but does not create the file as I wish:
Code:
void saveFile (char** list, int size, char* filename)
{
int i, length;
printf("\nPlease enter the name of the file to which you would like to save your output:\n");
printf("\tOnly use alphabetical characters, numbers, or '_'\n");
printf("\t\tMax of 15 characters per name\n");
scanf("%15s", filename);
FLUSH;
strcat(filename, ".txt");
fp2 = fopen(filename, "w");
if(!fp2)
MEM_ERROR;
for(i = 0; i < size; i++)
{
fputs(list[i], fp2);
fputs("\n", fp2);
}
printf("\n\t%s has been created succesfully\n\n", filename);
fclose(fp2);
return;
}
I appreciate all feeback