Skip to main content
added 53 characters in body
Source Link
Vlad from Moscow
  • 313.1k
  • 27
  • 204
  • 358

From the C Standard (6.7.9 Initialization)

3 The type of the entity to be initialized shall be an array of unknown size or a complete object type that is not a variable length array type.

So instead of this declaration with an initializer

int marks[n]={0};

use

int marks[n];
memset( marks, 0, n * sizeof( int ) );

Pay attention to that n may not be equal to zero.

From the C Standard (6.7.9 Initialization)

3 The type of the entity to be initialized shall be an array of unknown size or a complete object type that is not a variable length array type.

So instead of this declaration with an initializer

int marks[n]={0};

use

int marks[n];
memset( marks, 0, n * sizeof( int ) );

From the C Standard (6.7.9 Initialization)

3 The type of the entity to be initialized shall be an array of unknown size or a complete object type that is not a variable length array type.

So instead of this declaration with an initializer

int marks[n]={0};

use

int marks[n];
memset( marks, 0, n * sizeof( int ) );

Pay attention to that n may not be equal to zero.

Source Link
Vlad from Moscow
  • 313.1k
  • 27
  • 204
  • 358

From the C Standard (6.7.9 Initialization)

3 The type of the entity to be initialized shall be an array of unknown size or a complete object type that is not a variable length array type.

So instead of this declaration with an initializer

int marks[n]={0};

use

int marks[n];
memset( marks, 0, n * sizeof( int ) );