2

I'm probably facing the stupidest error so far. I was studying for my programming final exam in Visual Studio 2022 and my arrays suddenly stopped working. I define the array like this,

int arr[10] = {};

But when I try to use array functions for my array,

arr.

After putting '.', IntelliSense says "No members available" and no array functions listed.

Is this a bug or am I just missing something here?

Thanks a lot.

unitydevsz
  • 33
  • 3

1 Answers1

9

What you have initialised is C-style array (as @UnholySheep has already pointed out).

// C-style arrays

// This allocates a C-style array of 10 elements of type int
int myArray[10];

// C++ style arrays

// Include the array implementation provided by libc++
#include <array>

// This allocates C++ style array
std::array<int, 10> myArray;

With C++ style arrays you'll get member functions like end(), begin(), etc, but not with C-style arrays.

Also if you are new to the language, I would suggest you to look at cppreference for the documentation for the language features, it's quite accurate. https://en.cppreference.com/w/cpp/container/array is the link for documentation for std::array

Yaksh Bariya
  • 106
  • 3