I am writing a program that translates letters into morse code and then transmits them to an LED and blinks. I am not able to return the value ".- -..."
#include <stdio.h>
#include <string.h>
char *encode()
{
char *name = "AB";
char name_m[100] = "";
for (int i = 0; i < strlen(name); i++)
{
if (name[i] == 65)
{
strcat(name_m, ".- ");
}
else if (name[i] == 66)
{
strcat(name_m, "-...");
}
};
printf("%s", name_m);
return name_m;
}
int main()
{
char *name_m;
name_m = encode();
printf("\n%s", name_m);
}
main.c:22:10: warning: function returns address of local variable [-Wreturn-local-addr]
22 | return name_m;
| ^~~~~~
.- -...
(null)