|
|
C interview question:
Why doesn't the following statement work?
char str[ ] = "Hello" ; strcat ( str, '!' ) ;
Answer:
The string function strcat( ) concatenates strings and not a character.
The basic difference between a string and a character is that a string
is a collection of characters, represented by an array of characters
whereas a character is a single character. To make the above statement
work writes the statement as shown below: strcat ( str, "!" ) ;
|
|
|
|