lundi 29 juin 2015

Why memset is not working with array container in c++11?

#include <iostream>
#include <array>
#include <cstring>

using namespace std;

int main ()
{
  array<int,5> A ;
  memset(A,0,sizeof A);
  for(int i=0;i < 5;i++){
        cout<<A[i]<<" ";
}

   return 0;
}

When I run the program, compilation error occured.

But memset works well when I use int A[5] instead of array<int,5> A. Why memset is not working with container array as either way is used to define fixed size array?

Aucun commentaire:

Enregistrer un commentaire