Home »

Why doesn't the following statement work?

Question ListCategory: cWhy doesn't the following statement work?
jessica537 author asked 2 years ago
1 Answers
alisataylore190 author answered 1 year ago

char str[ ] = "Hello" ;
strcat ( str, '!' ) ;

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, "!" ) ;

Please login or Register to Submit Answer