2008年2月18日 星期一

sizeof vs strlen

char cname[50] = "";

int i = strlen(cname);
int j = sizeof(cname);


Result:

i = 0;
j = 50;

strlen: 計算目前char的長度(Get the length of a string.)
sizeof: The sizeof operator yields the size of its operand with respect to the size of type char

透過Facebook分享

沒有留言: