Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   How to creat two dimension array in the heap (http://www.go4expert.com/forums/creat-dimension-array-heap-t4424/)

falcon eyes 25May2007 17:47

How to creat two dimension array in the heap
 
Hi All
I'm using MS-VStudio 2005and want to creat two dimension array in the heap(free store )
but when i write the code
float *pFloat;
pFloat=new float[3][5];

and compile the profram i got the following error

error C2440: '=' : cannot convert from 'float (*)[5]' to 'float *'
1>Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


so could someone please tell me what's wrong in my code

shabbir 25May2007 18:28

Re: How to creat two dimension array in the heap
 
You have posted it as an Article under the Article / Source code section. I have moved it to the Queries and Discussion forum. Please take care that you don't repeatedly post the query as an article.

falcon eyes 25May2007 18:47

Re: How to creat two dimension array in the heap
 
Thanks and sorry

DaWei 25May2007 22:23

Re: How to creat two dimension array in the heap
 
Code:

    float (*pFloat)[5] = new float [3][5];

falcon eyes 27May2007 04:27

Re: How to creat two dimension array in the heap
 
Thanks
i will try it and if i have any notes i will post it

falcon eyes 29May2007 18:35

Re: How to creat two dimension array in the heap
 
Please DaWei
when i tryed the code u suggested
float (*pFloat)[5] = new float [3][5];
in my code i got this error
error C2040: 'pFloat' : 'float (*)[5]' differs in levels of indirection from 'float *'
So what's wrong do u have any suggestions[I]

tailhook123 30May2007 22:10

Re: How to creat two dimension array in the heap
 
http://support.microsoft.com/kb/104639 should cover all the problems involved and the workarounds.

DaWei 31May2007 01:01

Re: How to creat two dimension array in the heap
 
Works for me. Perhaps you have defined it otherwise, elsewhere.


All times are GMT +5.5. The time now is 19:29.