What type should be used to loop through an array? [duplicate]
问题 This question already has answers here : What is the correct type for array indexes in C? (9 answers) For iterating though an array should we be using size_t or ptrdiff_t? (3 answers) Closed 9 months ago . Let's have this array: char arr[SIZE_MAX]; And I want to loop through it (and one past its last element): char *x; for (i = 0; i <= sizeof(arr); i++) x = &arr[i]; (Edited to add some valid code with pointers). What is the most adequate type for i ? I accept non-standard types such as POSIX