初学者关于编程习题求赐教。
#include<iostream>#include<cstring>
int main()
{
using namespace std;
const int size=20;
char firstname[size];
char lastname[size];
char fullname[2*size+1];
cout<<"enter your fist name:";
cin>>firstname;
cout<<"enter your last name:";
cin>>lastname;
strncpy(fullname,lastname,size);
strcat(fullname,",");
strncat(fullname,firstname, size);
fullname[size-1];
cout<<"here's the information in a single string:"<<fullname<<endl;
return 0;
}
上面红色字的地方不太明白,就是[2*size+1]和[size-1]是什么意思或者起了什么作用?本人愚笨自学看书没看懂,希望好心人能帮帮我,最好能解释的直白一点,哈。