What's the difference between this function parameter stringLength(char string[]) to stringLength(char *string), shouldn't the first one not allow the incrementation(string = string +1) that has a comment on the code below?
#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
", s);
printf("%d
", stringLength(s));
}
See Question&Answers more detail:os