i read C Programming Language chapter 2-2.8 and wrote a strcat program
Code:
#include <stdio.h>
void cat(char s[],char t[]);
main()
{
char s[]="Hello ";
char t[]="World";
printf("%s\n",cat(s,t));
}
void cat(char s[],char t[])
{
int i,j;
i=j=0;
while(s[i] != '\0')
i++;
while((s[i++]=t[j++]) != '\0');
}
when i try to compile using gcc i get
In function `main':
11: invalid use of void expression
Why is that invalid?
then i replace void cat(... with int cat(... and it compiles but when i run it , it prints crap like
42@øÿ¿Døÿ¿ÌH@î@World