We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I want to use two dimensional array on realview compiler with type A[n][10] where n is an variable of type unsigned char. but it show an error.
That's because you cannot do that. Arrays must have a predefined size during compilation, unless constructed at runtime using dynamic memory allocation. Please have a look at a fundamental C programming language study book.
my code example is unsigned char n; unsigned char A[n][10]; function { n =5; A[1][0] = 2; A[1] [1] = 4; }
how to allocate dynamic memory for two dimensional array in c in realview compiler
The dynamic memory allocation just allocates memory - it neither knows nor cares how you're going to use that memory.
So just look-up "dynamic memory allocation" in the Realview compiler Manual...
Before talking abou Realview specifics, you do know how to do this in plain, ANSI 'C', don't you...?
Note that dynamic memory allocation is often best avoided in embedded systems.
What, exactly, are you trying to achieve here?
If you explain what you're actually trying to achieve, people may be able to offer better approaches - rather than just discuss a potentially broken approach...
at the time of compilation , i do not know the size of multidimensional array that's why i want to know about dynamic memory allocation for two dimensional array in realview compiler
"at the time of compilation , i do not know the size of multidimensional array that's why i want to know about dynamic memory allocation for two dimensional array in realview compiler"
You were asked to explain what you are actually trying to achieve. Using a 2D array of unknown size may or may not be a good way to do what you need - but nobody can comment on that without knowing what, exactly, you are actually trying to do!