hey there, i need some help in understanding pointers. this is an example from school but i cant quite figure i out. i know the basis of pointers but could someone give me some more info.
#include <stdio.h>
#include <string.h>
int string_len(char *s);
int main() {
char s[80];
strcpy(s,"Hello");
printf("length of %s is %d\n",s,string_len(s));
return 0;
}
int string_len(char *s) {
char *p;
p = s;
while (*s != '\0') {
s++;
}
return s-p;
}
Also the use of pointers with structures and passing on arguments onto functions confusing me.
any tips on what to keep in mind when using pointers in general and when using structure pointers?.
-regards:)
edit: could someone please give me a simple example of pointers to structures and argument passing?