I have come across a problem while writing a fairly simple program. I have a statically allocated vector as a global variable and in a function I'm trying to change the values of the elements and that is when the program stops and says segmentation fault. The code is something like this:
int a[10] = {0,0,0,0,0,0,0,0,0,0};
...
int bla(int i){
...
a[i] = a[i] + i%3; //segmentation fault at this line
...
}
In the main function I have a "for" in which i takes values from 0 to 9.
Problem solved! Thank you :)