h****b 发帖数: 157 | 1 size_t sizestr(const char *s)
{
const char * const start =s;
while(*s!='\0')
{
s++;
}
return(s-start);
}
which state below is true
1)the proposed return type deviates standard
2)the suggested implementation is incorrect because a differencing
operation is performed on pointer of unlike type
3) C does not support autoincrement for const qualified pointers. the body
of the loop is invalid
4) By the standard of C, the implementation miscalculates the length of
string |
Q**g 发帖数: 183 | 2 1). ptrdiff_t
【在 h****b 的大作中提到】 : size_t sizestr(const char *s) : { : const char * const start =s; : while(*s!='\0') : { : s++; : } : return(s-start); : } : which state below is true
|
f******y 发帖数: 2971 | 3 3
【在 h****b 的大作中提到】 : size_t sizestr(const char *s) : { : const char * const start =s; : while(*s!='\0') : { : s++; : } : return(s-start); : } : which state below is true
|
g**********d 发帖数: 24 | 4 我也没看出错来。编译的代码运行成功。 请高人指点 |
B*******g 发帖数: 1593 | 5 2楼牛人答对了
【在 h****b 的大作中提到】 : size_t sizestr(const char *s) : { : const char * const start =s; : while(*s!='\0') : { : s++; : } : return(s-start); : } : which state below is true
|
a****l 发帖数: 8211 | 6 Actually the code is probabily very correct in every way, but the only "problem" is that it might not be doing what the coder "think" it should be doing. On the other hand, the original question did not state what it is supposed to do, so in this case it is hard to say whether anything is wrong with this code.
This is a typical "school" style question, where you would need to guess what is the intention of the question thus choosing the answer.
【在 g**********d 的大作中提到】 : 我也没看出错来。编译的代码运行成功。 请高人指点
|