See How to concatenate 2 strings in C?.
Also, you should use strcat
.
Check out this tutorial.
An example in this is:
/* Example using strcat by TechOnTheNet.com */
#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[])
{
/* Define a temporary variable */
char example[100];
/* Copy the first string into the variable */
strcpy(example, "TechOnTheNet.com ");
/* Concatenate the following two strings to the end of the first one */
strcat(example, "is over 10 ");
strcat(example, "years old.");
/* Display the concatenated strings */
printf("%s\n", example);
return 0;
}
In your case it would be:
char file_name[200 + 200];
file_name [0] = '\0' // To make sure that it's a valid string.
strcpy (file_name, str); // Concatenate `str` and `file_name`
strcat(file_name, str2); // Concatenate `str2` and `file_name`
out_file = fopen(file_name, "w"); // Open the file.
Also, thanks to 'laerne' for pointing out some mistakes.