On the outset users might see the command strcat and think that the string str having value “Exforsys” would get concatenated with ‘!’. But this will not happen
Surprised to hear this!!!!!
But there is an interesting fact to know in the above code. The string handling function strcat() concatenate only string and does not concatenate characters.
In other words string which are collection of characters and which is represented in C programming language as array of characters can be concatenated using the function strcat(). But in the above code the second parameter represented in strcat() function is not string but character represented s ‘!’ and so cannot be sued in strcat().
So in summary to make the above code work the second parameter must be represented as “!” to make it as string and if such a change is made the string “Exforsys” gets concatenated with “!” to give Exfrosys!
What will happen with the following code? #include <string.h> main() { char str[ ] = "Exforsys" ; strcat ( str, '!' ) ; }
On the outset users might see the command strcat and think that the string str having value “Exforsys” would get concatenated with ‘!’. But this will not happen
Surprised to hear this!!!!!
But there is an interesting fact to know in the above code. The string handling function strcat() concatenate only string and does not concatenate characters.
In other words string which are collection of characters and which is represented in C programming language as array of characters can be concatenated using the function strcat(). But in the above code the second parameter represented in strcat() function is not string but character represented s ‘!’ and so cannot be sued in strcat().
So in summary to make the above code work the second parameter must be represented as “!” to make it as string and if such a change is made the string “Exforsys” gets concatenated with “!” to give Exfrosys!
Profile Answers by GeekAdmin Questions by GeekAdmin
Questions by GeekAdmin answers by GeekAdmin