Your biggest problem is fooling around with multiple indices when you could more easily reuse one variable for that purpose:
Code:
void concat ( char result[], char first[], char middle[], char last[] )
{
int i, j = 0;
for ( i = 0; first[i] != '\0'; i++ )
result[j++] = first[i];
result[j++] = ' ';
for ( i = 0; middle[i] != '\0'; i++ )
result[j++] = middle[i];
result[j++] = ' ';
for ( i = 0; last[i] != '\0'; i++ )
result[j++] = last[i];
result[j++] = '\0';
}
>first[ i ] != NULL
This is generally a bad idea, the NULL macro may not be the same as the nul character ('\0') so you really shouldn't use them interchangeably.
This function could be simplified greatly by using the standard library as well:
Code:
void concat ( char result[], char first[], char middle[], char last[] )
{
sprintf ( result, "%s %s %s", first, middle, last );
}
-Prelude