这个函数参数stringLength(char string [])与stringLength(char*string)之间的区别是什么,第一个不允许增量(string = string +1)对下面的代码有评论?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int stringLength(char string[]) {
int length = 0;
while(*string) {
string = string + 1; // I can do it here
length++;
}
return length;
}
int main(void){
char s[] = "HOUSE";
s = s + 1; // I can not do it here
printf("%s\n", s);
printf("%d\n", stringLength(s));
}
Run Code Online (Sandbox Code Playgroud)