How do I check if the current index is the last index in the table?
source link: https://www.codesd.com/item/how-do-i-check-if-the-current-index-is-the-last-index-in-the-table.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How do I check if the current index is the last index in the table?
How do I say?
for (i = 0; i < arraySize; i++)
{
if (someArray[i + 1] !NULL)
{
//do this
}
else
{
//do something else
}
}
In other words, I want to check if the current index is the last index in the array. The current code is my best guess but it isn't working.
EDIT: It is an integer array and i less than arraySize not 0
EDIT 2: The code inside my for loop is more complicated than the example above but I can't paste all the code as it is top secret atm. I have many nested if statements. if(i==arraySize-1)
helped me to solve the problem. Thanks.
Following line will give you count of items in your array:
count = sizeof (intMyArray)/sizeof(intMyArray[0]);
if you know arraySize then:
if(i==arraySize-1){
//last element of array
}
Related Articles
How do I check if the tables are equal in javascript?
How do I check whether the table has an object or not?
Entity Framework - How do I check if the table exists?
How do I check if the table already contains a certain value?
How do I check if the user is in the admin part of Drupal?
How do I check if the entry in an array has failed?
Python - how to check if the table exists?
How do I check if the result is a fraction
How do I check if the data already exists in the combobox list?
How do I check if the cursor is on an item?
How do I check if the date is in a list of date strings?
How do I check if the operating system is Sun Os or Unix or Solaris by bashrc
How do I check if the controls in a usercontrol contain a value?
How do I check if the JSON data is an object or set of objects?
How do I check if the object is a DOM element?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK