| | |
Dynamic Memory allocation
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
01 Why i am not able to do this
other the
02 Why i am not able do access through pointer dx by
03 why i am not able to directly initialize array of new dynamically alloc. mem to
C++ Syntax (Toggle Plain Text)
int* px; px = new int[2][2];
px = new int[2*2]; is there any other method02 Why i am not able do access through pointer dx by
dx[1][2] other than by using dx[1*7+2] cpp Syntax (Toggle Plain Text)
static float mat[5][7] = { -5, -4, 0, 0, 0, 0, 0, 6, 4, 1, 0, 0, 0, 24, 1, 2, 0, 1, 0, 0, 6, -1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 2 }; float *dx=&sim_max[0][0]; cout<<dx[1][0];
03 why i am not able to directly initialize array of new dynamically alloc. mem to
C++ Syntax (Toggle Plain Text)
float *dx= new float[5*7] ( -5, -4, 0, 0, 0, 0, 0, 6, 4, 1, 0, 0, 0, 24, 1, 2, 0, 1, 0, 0, 6, -1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 2 );
Last edited by Rhohitman; Oct 2nd, 2009 at 3:38 pm.
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Well Dynamic 2D arrays take a little more complexity.This is mainly because when you declare something like this
What you are trying to do is assigning a pointer array to a pointer itself.
THe
So now you have a 2d array whose elements you can access.
C++ Syntax (Toggle Plain Text)
int *p; p= new int [2][2];
THe
new int [2][2] converts itself into a pointer array in this case it is something like int * [2] So In order to Dynamically Create a 2D array you will need to do something like this. C++ Syntax (Toggle Plain Text)
int *p,**q; q=new int* [2]; q[0]=new int [2]; q[1]=new int [2]; delete []q[0]; delete [] q[1]; delete [] q;
Thanx Sky Diploma
here things got too much complicated
i guess i have to use the loop for assigning the value inside it..
here things got too much complicated
C++ Syntax (Toggle Plain Text)
Temp2=T1->dx[i*T1->n+T1->n-1] / T1->dx[i*T1->n+pivot_j];
i guess i have to use the loop for assigning the value inside it..
Last edited by Rhohitman; Oct 2nd, 2009 at 4:30 pm.
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
![]() |
Similar Threads
- Dynamic memory allocation/reallocation of an Integer array (C++)
- Error with Dynamic Memory Allocation (C++)
- Malloc/Calloc Dynamic Memory Allocation. (C++)
- Please Help Dynamic Memory Allocation. (C++)
- regarding dynamic memory allocation (C)
- Dynamic memory allocation homework (C++)
Other Threads in the C++ Forum
- Previous Thread: deallocate allocated memory
- Next Thread: Search position for date in file
Views: 291 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll dynamic encryption error file forms fstream function functions game givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linker linux loop looping loops map math matrix memory microsoft newbie news number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort stream string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






