Your program has a lot of problems; you never initialize firstthree
, for example.
The reason you're getting the specific error you're seeing is because of this call:
strcat(firstthree, s[i]);
s
is a char *
, so s[i]
is a char
, but strcat
expects both parameters to be pointers to null-terminated strings. What it seems you want is something like:
char firstthree[4] = { 0 };
for (int i = 0; i < 3; i++)
{
firstthree[i] = s[i];
printf("Hello %s\n", firstthree);
}