| | |
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
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamiccharacterarray email encryption error file format forms fstream function functions game givemetehcodez graph homeworkhelp iamthwee ifstream input int java lib library lines list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sorting spoonfeeding string strings struct temperature template templates text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






