#C++ Code Help
30 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
cout << end(nums) - begin(nums) << "\n";
How's end and begin working together to get me the array size ?
end gives you a pointer one past the last element of the array
begin gives you a pointer to the first element of the array
the difference of two pointers is the number of array elements between them
So end is not pointing to the last number
Its pointing to an imaginary number that comes after the last number
its one past it
Okay but it still 5
I mean When I count the numbers, its 5, or 4 when I start with zero
wait yes, it's the array size
We count from zero right?
on indexing
but it contains 6 elements
Do we start counting from the second number?
^ this is basically it
shouldnt have confused
i just don't understand it
What you mean guys
Can i Skip it cuz i really can't understand it
I watched yt videos and the Indian guys saying that end is pointing into an imaginary number
it's pointing one past the last element