This is the code I wrote trying to use malloc ( and I didn't free the allocated space 'cause I didn't know how to ). The code is error free to the compiler but the output is still not what I expected.
the output is:
char* linker( char* , const char*, int len, int len2 );
int main ( void )
char* s1 = "Hellooo,";
char* s2 = "World!";
len = strlen(s1);
len2 = strlen(s2);
printf("\n %s \n", linker(s1, s2, len, len2));
char* linker ( char* str1, const char* str2, int len, int len2 )
str1 = malloc( len + len2 + 1 * sizeof(char));
return strcat ( str1, str2 );
[note : the $ sign only represents the Linux's bash shell which apears at the end of the execution and it's not a part of the output.]
Any help on this?
I thought it might have something to do with calling linker() in a printf function and sending int values to linker() while printf is looking for strings. But the returning value of linker is still a string!
Thanx for any help