markdot
asked on
C++ strcpy
void main()
{
char s[100]={'a','b','c','d','e ','f','g'} ;
strcpy(s+4,s+3);
cout<<s<<endl;
return;
}
I thought it should be abcddefg, but it is abcdddfg. Can you explain in detail?
{
char s[100]={'a','b','c','d','e
strcpy(s+4,s+3);
cout<<s<<endl;
return;
}
I thought it should be abcddefg, but it is abcdddfg. Can you explain in detail?
ASKER
Then, how can we shift the sub-string "defg" in char s[100]={'a','b','c','d','e ','f','g'} ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is what I need!
http://www.opengroup.org/onlinepubs/000095399/functions/strcpy.html
If copying takes place between objects that overlap, the behavior is undefined.