How to get the number of elements in a list (size of a list) in C++

1 Answer

0 votes
#include <iostream>
#include <list>

using std::list;
using std::cout;
using std::endl;

int main()
{
	list<int> lst{ 1, 3, 8, 23, 99, 12, 100, 7 };
	
	cout << lst.size() << endl;
}


/*
run:

8

*/

 



answered Jan 20, 2018 by avibootz
...