Attempts to modify the read-only argument in an assignment statement from within the function. - C Function

C examples for Function:Function Parameter

Description

Attempts to modify the read-only argument in an assignment statement from within the function.

Demo Code

#include <stdio.h> 
void modifyArray(const int[]);

int main()//from  w w w. j a v  a 2  s  . c  o m
{
   int iNumbers[3] = { 2, 4, 6 };
   modifyArray(iNumbers);

   for (int i = 0; i<3; i++) {
      printf("%d", iNumbers[i]);
   }
}
void modifyArray(const int num[]) {
   int x;
  // for (x = 0; x < 3; x++)
//      num[x] = num[x] * num[x]; //this will not work!  
}

Related Tutorials