If you declare a pointer and a C char array such that:
char arr[100];
char *ptr;
Am I correct in saying that
*ptr is the same as ptr[] in other words it's a pointer to the first element in a dynamic array?
Then if I were to loop through a NULL terminated char array such that
printf("Enter a string");
gets(arr);
char *ptr = someCharString;
int increment;
while(*ptr++ != '\0')
increment++;
So increment now gives the length of the string(assuming it's NULL terminated). I assume this is how strlen works..
So is this the same as saying ptr[length_of_char_string]
How do I reset *ptr back to ptr[0] so that I can loop through *ptr now that I have the length such as,
for(int i = 0;i < increment;i++){
if(*ptr++ = 'a'){//Need ptr to start at the first element again
//Do stuff
}
}