Hi,
This is my code:
#define NUMBER_OF_ROWS 50 #define NUMBER_OF_COLS 2 unsigned int Array[NUMBER_OF_ROWS] [NUMBER_OF_COLS] = { {100,50}, {20 ,10 }, {16 , 8 }, {14 , 7 }, {12 , 6 }, {11 , 5.5 }, {10 , 5 }, {9.1, 4.55}, {2 , 1 } and so on until 50 rows..};
The problem is I have 50 elements needed for a lookup table, but the following error occur: Array.h(57): error C242: 'array[]': too many initializers
When I initialize number of rows to 45, no error prompt. I need to use all the 50 elements. Is this the only way for me to create a lookup table? Can someone guide me on using more simpler method? Please help me. Thanks.
So - why (?) are you so stubborn?
Haven't you realized that there are people here who have 10, 20 or even more years of experience and actually do know for a fact that your code will produce the wrong result because your floating point values will be converted to integer values - and losing the decimal part?
Why do you think the language have both integer and floating point data types of an integer data type can store a floating point value?
Your code is a failure as written. You could rewrite it to use fixed-point integer arithmetic and get great results. But that demands that you (!) do spend some time learning. Right now, you are just spending your time assuming. Well ass-u-me isn't a good way to write software. Now remove the blinders and start to learn. 9.1, after storing it in an int is no more 9.1. That should be 100% obvious if you decided to actually think about it.