c89- все статьи тега


Почему вы должны использовать strncpy вместо strcpy?

Edit: я добавил источник для примера. я наткнулся на : char source[MAX] = "123456789"; char source1[MAX] = "123456789"; char destination[MAX] = "abcdefg"; char destination1[MAX] = "abcdefg"; char *return_string; int index = 5; /* This is how strcpy works */ printf("destination is originally = '%s'n", destination); return_string = strcpy(destination, source); printf("after strcpy, dest becomes '%s'nn", destination); /* This is how strncpy works */ printf( "destination1 is originally = '%s' ...