Could anyone explain the link between strings and pointers?
I am really confused on how strings and pointers are linked together and why we don't have to use the indirection operator(*) for dereferencing as is the case for normal arrays. for example I am allowed to assign a value to string at the time of declaration but not afterward char s[5] = "John" ; RIGHT .. .. s= "John"; WRONG similarily I sometimes have to use the * operator for strings other times I don't. Ex: in the case of int arrays, we have to use the * operator if we want to print a value but not in the case of strings. Just printf("%s", s); will print out John. Why are we not using *s instead? Another trouble I am having is with storing multiple names in an array of char pointers. If I write *s[] = {"John", "Adams", "Charlie"....}; it works but if I want to input the names from the user, a statement like scanf("%s, s[0]); does not work. And, what's even more confusing now is that to print out a name, I have to use the * operator printf("%s, *(s+2)) ; or simply s[2] All this is very confusing to me as I don't really know when to use the * operator and when not to. It's all cuz the rules about pointers we learned in arrays do not hold true to strings. 1) We do not always use & 2) We do not always use * 3) We even are not allowed to assign using = operator Could anyone kindly clear all these doubts and explain what really is going inside the computer's memory when using pointers and strings. Also, could anyone suggest a resource that might help clear all these doubts and help solidify my concepts Your help is highly appreciated. Thanks:)