In a C-program I am trying to create a textfile where the file name should be based on the input to one or two char arrays in a structure.
At the moment I query the filename like this:
printf("Type a filename:");
scanf("%s", &filename);
strcat(&filename, ".txt");
pFile=fopen(filename,"a");
…but let's say my input to my char array is John , how could this input be used to create the filename John.txt ?
..or even better: combine a name from two char arrays:
fgets(pIndex->name, 20, stdin); //lets say input here is John
fgets(pIndex->country, 20, stdin); //...and input here is England
to generate a filename like JohnEngland.txt
Thanks a lot !
-Espen