-4

I have an const array in global scope like this:

const long array_test[5] = {1, 2, 3, 4, 5};

How do I modify the elements of the above array at runtime using a pointer?

Tersosauros
  • 883
  • 1
  • 12
  • 22
gautham
  • 55
  • 1
  • 5

2 Answers2

0

In no way. You can't modify const objects.

0

You can't. The const keyword is used to create a read only variable. Once initialised, the value of the variable cannot be changed but can be used just like any other variable. That means, a const qualified variable must not be assigned to in any way during the run of a program.

haccks
  • 104,019
  • 25
  • 176
  • 264