Convert integer to string in C [duplicate]

this question already has answers here : Error calling function that returns string in C (3 responses) returning function string straight and with array (2 responses) return string in C for manipulation outside the function in which it was declared (2 responses) Closed 11 months ago.

I have a problem with converting an integer to string in the scope of a function where the return of the conversion is given as null and I don't know why.


#include <stdio.h>

char *getTexto(int num) {

    char numTxt[7];

    itoa(num, numTxt, 10);

    if ( num % 3 == 0 ) {
        if ( num % 5 == 0 ) {
            return "TicTac";
        }
        else {
            return "Tic";
        }
    }
    else if ( num % 5 == 0 ) {
        return "Tac";
    }
    else {
        return numTxt;
    }

}

int main() {

    for ( int x = 1; x <= 100; x++ ) {
        printf("\n%s", getTexto(x));
    }

    return 0;
}
Author: Noronha, 2020-03-17