+ 1

What is the output of this c++ code which has strcat and strspn function?

I have this code. the output of compiler were 11 but I didn't undrestand why? #include <iostream> #include<string.h> using namespace std; int main() { char s1[]="abcdefgh"; char s2[]="ijkl"; strcpy(s2,s1); strcat(s2,s1); cout<<strspn(s1,s2); return 0; }

16th Nov 2017, 2:56 PM
manizheh arian
manizheh arian - avatar
3 Antworten
+ 1
note one thing strcpy() can copy address not content.
16th Nov 2017, 4:17 PM
Bhavin Kundaliya
Bhavin Kundaliya - avatar
0
compiler ptoduce 11. when length of destination of strcpy is less than source string,what happened?
16th Nov 2017, 3:11 PM
manizheh arian
manizheh arian - avatar