I am very new in C language. I was trying to use strcat function.
#include
#include
int main(int argc, const char *argv[])
Both of the code snippet invoke undefined behavior. In the first snippet s1 has not enough space to hold any other character than six characters.
In the second snippet you are trying to modify a string literal. Any attempt to modify a string literal lead to undefined behavior.
Read strcat man page:
[...] The strings may not overlap, and the
deststring must have enough space for the result. Ifdestis not large enough, program behavior is unpredictable; buffer overruns are a favorite avenue for attacking secure programs.