How to find the size (length) of string array in C++

1 Answer

0 votes
#include <iostream>
#include <string>

using std::cout;
using std::endl;
using std::string;

int main()
{
	string arr[] = { "c++", "java", "php" };

	cout << sizeof(arr) / sizeof(arr[0]) << endl;

	return 0;
}

/*
run:

3

*/

 



answered May 7, 2018 by avibootz
edited May 7, 2018 by avibootz

Related questions

2 answers 209 views
1 answer 184 views
2 answers 197 views
1 answer 142 views
1 answer 280 views
2 answers 191 views
2 answers 157 views
...