Wednesday, November 13
Two Dimension Pointers C++
Pointers are very useful construct of C++ programming language and what is more useful is 2d pointers.
The pointers are special variables pointing to a memory location or a variable where as an array is a collection of those variables. A 2d pointer is a pointer which is pointing to array of pointers.
e.g.
The pointers are special variables pointing to a memory location or a variable where as an array is a collection of those variables. A 2d pointer is a pointer which is pointing to array of pointers.
e.g.
//Assign an array of 5 nameless pointers to a 2d pointer
int **pointer = new int*[5];
//then assign values to each array
for(int i=0;i<5; i++)
{
pointer[] = new int[10];
}
//now we have a 2d pointer which can be also accessed as array
pointer[2][9] ; //this is third row and 10th element
very good yaar ;)
ReplyDelete-~Hacker says C++~-
ReplyDeletea correct io in line13 here pointer[i] has to be written
ReplyDeleteThanks sir :)
ReplyDeletedun knw who shared it but worth reading post.
ReplyDeleteA post for starters of arrays and pointers :P
ReplyDeleteNice information and thanks for posting this here! Please keep sharing more
ReplyDeleteinformation like this further in future. You can find more information on C++
Tutorials in the following link..
CPP Tutorials