#include <iostream>
using namespace std
#include <string.h>
int main(){
char token[] = "some random string";
char c[23];
strcpy( c, token);
strncpy(c, token, 5);
c[strlen(c)] = '\0';
cout<<c;
return 0 ;
}
Мой результат: some random string
. Но я ожидаю, что это будет: some
. Кто-нибудь может объяснить, почему он так себя ведет?
std::string
. - person Rapptz   schedule 25.12.2012