C-код ведет себя странно.
#include<iostream> using namespace std ; int main () { char *c = new char(100); strcpy( c , (char*)"http://localhost:4000/index.html") ; strcpy ( c, &c[6] ) ; printf(" url is %s\n" , c ) ; return 0 ; }
Этот код выводит :
URL-адрес /localhost:ndex.htmlx.html
Что я уже пробовал:
I wanted to output /localhost:4000/index.html. I know that this can be done through assigning c = c+ 6 but I want to know how does the above code works ? Where does the number 4000 disappear and from where does the extra stuff comes from ?