adding a space to a string
how do i add a space to the end of a string?
this function takes the users first, middle, and last name. then it puts them all together in the string result. the output shows no spaces between the first, middle and last names. how do i add teh space.
i've tried doing something like...
result[ i ] = result[ i + ' ' ] ;
but it has no effect. when i put that inside the for loop, it displayed these weird characters.
Code:
void concat( char result[], char first[], char middle[], char last[] )
{
int i, j, k ; /* Loop counters */
for ( i = 0 ; first[ i ] != NULL ; i++ ) /* Copy first to the */
result[ i ] = first[ i ] ; /* string result */
for ( j = 0 ; middle[ j ] != NULL ; j++ ) /* Copy middle to the end of string */
result[ i + j ] = middle[ j ] ; /* result from where we left off. */
for ( k = 0 ; last[ k ] != NULL ; k++ ) /* Copy last to the end of string */
result[ i + j + k ] = last[ k ] ; /* result from where we left off. */
result[ i + j + k ] = '\0' ; /* Add the null byte to the end of the string */
}