I know Python, and I'm learning C. Both langs have for loops. Python's nicely iterates over a collection of unknown length. C's usually has you specify the length of the collection at compile time, but what if the length is unknown?
My best newbie guess: you terminate the collection with NULL, or you write an iteration function that returns some end-of-collection value when it's done.
If you try to iterate beyond the end on an array in C, you'll get an array out of bounds error and crash. So, yeah, you basically need to use a null termination or know your bounds.
array out of bounds error
No, you won't. You'll may end up grabbing random data from the memory, and either fill your buffer with all kinds of junk left over from other code, or you'll get an access violation/segmentation fault at the end of that allocation block (depends on how your OS manages memory, if it's something like DOS or certain embedded systems, the whole memory could end up being valid).
Depends on the data structure. Usually with unknown length you're iterating through a linked list, which terminates when the pointer to the next item is null.
collection
Here's your problem. C doesn't have "collections". for consists of 3 fields, all of which are optional: an initialization clause, a control expression (evaluated before each execution of the body, and the for loop only executes until the expression is false), and an expression that is evaluated after each execution of the body (usually to increment or decrement a variable that is part of the control expression). Then a statement (usually a block-statement) follows.
/* i is initialized to 0 */
for (int i = 0; i < 3; i++) {
/* when i < 3 evaluates to false, execution will go to the next line following the for block */
printf("%i", i);
/* i++ is executed after each iteration*/
}