Odd array assignment behaviors

Every time I assign my array (in the main function) values, regardless of what I tell it to assign, it only assigns every value to 0.
Any ideas as to how to fix this?

int main()
//Array to store each pixel’s graylevel value
double grayLevelsFromImage[width][height];

//TODO: Store image grayLevel Values in an Array
//TEMP: Here For Testing Purposes
//ERROR: Does not assign values. displays all 0
for (int i = 0; i < height; i++){
	for(int z = 0; z < width; z++){
		 grayLevelsFromImage[z][i] = 10;
		 //TEMP: Testing
		 printf("%d\n", grayLevelsFromImage[z][i]);


You’re printing integers(%d) instead of doubles.


A hint on how to do debugging in general:
The picture you have in your head is probably/hopefully correct. Don’t think about it a million times and ask “why doesn’t it work” because that’s not where the problem is. The problem is in all the places where you’re NOT looking. So instead, look at that “correct picture” in your head, and ask this: “how can I possibly break this code to generate such a bug.”

Think at a different level about your code, and you’ll find bugs that a debugger will never show you.:)

By the way, this was totally unrelated to CUDA and you should try it on a forum related to C programming.