I'm trying to write a function in C that gets an int as a parameter and returns a char array (or a string).
const char * month(int x)
{
char result[40];
if(x<=31) strcpy(result,"can be a day of the month");
else strcpy(result,"cannot be a day of the month");
return result;
}
But my function returns an int, not a string. I have read posts where people might have run into similar situations, but I can't understand how the pointer-type functions work and how to make them return what I want (I have documented a bit about pointers and I have an idea about how they work alone, but I have never tried to write a piece of code that adds some functionality to them, like making a solution more effective or something else.)