C pointer to const array. Also notice the size of the array is specified.
C pointer to const array I understand the following code: const char *someArray This is defining a pointer that points to types of char and the c Jul 23, 2025 · In C programming language, pointers and arrays are closely related. When used in an expression and not the subject of either the & or sizeof operators, they will evaluate to rvalues of type char * and const char * respectively, pointing at the first element of the array. org Dec 22, 2019 · Using pointers with Const, Void, and arrays in the C programming language. 1. It's important to understand that "constant" and const are two different things. Isn't the address of an array and thus of all its elements as well constant anyway? And if so, in a declaration like: char *const argv[] isn't the const qualifier redundant? There's not an array in your entire example. Pointers to constant. If something is constant, it's evaluated at compile time; for example, 42 and (2+2) are constant expressions. Making the pointer or a type like int const, just says "don't let this change inside its scope. Obviously you could bypass this last protection with a const_cast, but then you go into UB-land (it may result in a crash at runtime). cnitpunkdurbycrqsuqqlycxowvmmpsbsybhonxjpxltuweesmcgvbvzwdzurawhevpadhvusnt