can case statement be a part of array

Hello guys, i kind new to programming. I am doing project regarding robotic arm. Thus i put array function to the coding. In my coding there has many case statement. i don want the servo be element of array but i want the case statement be the element of array.

Can someone post an example of the coding please. Your help really appreciate.

I am doing project regarding robotic arm. Thus i put array function to the coding.

Non sequitur and the second sentence doesn’t make sense.

In my coding there has many case statement.

“case” is not a statement, it is a label in a switch statement.

i want the case statement be the element of array.

It can’t be.

Can someone post an example of the coding please

It would be better if you post your code - in code tags, read How to post code properly.

Pete

If I understand you correctly, your switch/case is growing out of hand. Are you already calling dedicated functions in the cases?

If so, the next step would be to put function pointers in an array. Than you can use the variable as an index in the array and execute the correct function. In that case you actually don't need a switch/case.

Note that the array needs have enough elements to cater for the highest number of the variable. So if you're variable can contain the numbers 1, 2 and 99, the array needs to be able to hold 99 elements; non-used elements can be set to NULL so you can test. If there is logic in the numbers in the variable (e.g. numbers from 0..9 and 90..99), you can possibly work around that; you can subtract 80 from the number if it's greater then 89.

Also note that the IDE probably will complain of you do not place the functions before you implement the array or don't use function prototypes.

Also note that your functions need to provide a consistent 'interface'; e.g. all of them must take the same amount of parameters and return the same type.