C: Add numbers to filename : I want to store data in different files. Therefore I want to create files as follows: `data_1.log`, `data_2.log`, ..., `data_N.log`. The appendix `.log` is not necessary but would be nice. All my approaches failed so far. Here is one sample that is probably close to what I need:

    #include <stdio.h>
    #include <string.h>
    
    char get_file_name(int k){ 
        int i, j;
        char s1[100] = "logs/data_";
        char s2[100];
        snprintf(s2, 100, "%d", k);
        for(i = 0; s1[i] != '\0'; ++i);
        for(j = 0; s2[j] != '\0'; ++j, ++i){
            s1[i] = s2[j];
        }
        s1[i] = '\0';
        return s1;
    }
    
    int main(){
    
        char file_name[100];
        for(int k=0; k<10; k++){
            // Get data
            // ...
            // Create filename
            strcpy(file_name, get_file_name(k));
            printf("%s", file_name);
            fp = fopen(file_name, "w+");
            // Write data to file
            print_results_to_file();
            fclose(fp);
        }
    
        return 0;
    }

At the moment I get the following errors which I don't understand:

    string.c: In function ‘get_file_name’:
    string.c:14:12: warning: returning ‘char *’ from a function with return type ‘char’ makes integer from pointer without a cast [-Wint-conversion]
         return s1;
                ^~
    string.c:14:12: warning: function returns address of local variable [-Wreturn-local-addr]
    string.c: In function ‘main’:
    string.c:24:27: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [-Wint-conversion]
             strcpy(file_name, get_file_name(k));
                               ^~~~~~~~~~~~~~~~
    In file included from string.c:2:
    /usr/include/string.h:121:14: note: expected ‘const char * restrict’ but argument is of type ‘char’
     extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
                  ^~~~~~
    string.c:29:9: warning: implicit declaration of function ‘print_results_to_file’ [-Wimplicit-function-declaration]
             print_results_to_file();
             ^~~~~~~~~~~~~~~~~~~~~
    /usr/bin/ld: /tmp/ccZDRebi.o: in function `main':
    string.c:(.text+0x190): undefined reference to `print_results_to_file'
    collect2: error: ld returned 1 exit status


Is there a more simpler way to create such filenames? I can't believe that there isn't one.