When I write the code it shows error
#include <bits/stdc++.h>
using namespace std;
int main()
{
int arr[] = {12, 3, 4, 15};
int n = arr.size();
cout << "Size of array is " << n;
return 0;
}
Compilation failed due to following error(s).
main.cpp:7:17: error: request for member ‘size’ in ‘arr’, which is of non-class type ‘int [4]’
7 | int n = arr.size();
| ^~~~
it also didn't work for vector array i tried that also can't understand the problem
std::vector<int>instead of a raw array.sizeof(arr)/sizeof(arr[0])or the non standard_countof(arr)which exists on some platforms.#include <bits/stdc++.h>-- I know you didn't get this from a reputable C++ book, which you should be using to learn C++. Instead, you probably got code from a dodgy C++ website and used this non-standard header.