Did you get any of these errors?
Code:
$ gcc -Wall -Wextra foo.c
foo.c: In function ‘main’:
foo.c:11:12: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘int’ [-Wformat=]
printf("%s",glew(a,b));
^
foo.c: In function ‘glew’:
foo.c:18:9: warning: implicit declaration of function ‘strcat’ [-Wimplicit-function-declaration]
c = strcat(a,b);
^
foo.c:18:9: warning: incompatible implicit declaration of built-in function ‘strcat’
foo.c:18:9: note: include ‘<string.h>’ or provide a declaration of ‘strcat’
foo.c:18:7: error: assignment to expression with array type
c = strcat(a,b);
^
foo.c:19:12: warning: return makes integer from pointer without a cast [-Wint-conversion]
return c;
^
foo.c:19:12: warning: function returns address of local variable [-Wreturn-local-addr]
Like this.
Code:
char* glew(char a[], char b[])
{
static char c[40]; // So it's value is preserved on function return
strcpy(c,a);
strcat(c,b);
return c;
}
Or like this, where the result array is provided by the caller.
Code:
char* glew(char a[], char b[], char c[])
{
strcpy(c,a);
strcat(c,b);
return c;
}