<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3975364399108407371</id><updated>2012-02-16T07:51:29.898-08:00</updated><title type='text'>c++ pointer</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default?start-index=101&amp;max-results=100'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>146</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5515049150731554855</id><published>2009-07-14T20:14:00.002-07:00</published><updated>2009-07-14T20:14:42.849-07:00</updated><title type='text'>How can I use pointers in C# programming?</title><content type='html'>There are several restrictions to using pointers in C#.  I've included a link to the MSDN section on using pointers in C# below.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I would encourage the use of objects instead of pointers if you can get away with it.  Pointers are considered "unsafe" types, and must be included in trusted assemblies (if compiled into an assembly) to be accessed.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I believe pointers in C# (or .NET for that matter) are allocated on the heap, unless you call stackalloc to explicitly allocate them on the stack.  They are declared with an * after the type declaration for multi-pointer declarations, or an * before the variable name for single pointer declarations.  Two asterisks indicate a pointer to a pointer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Also, any methods where a pointer is declared/used must be declared with an "unsafe" declaration before the method declaration.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You can obtain further information at the URL below.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How can I use pointers in C# programming?&lt;br&gt;The design of C# is to avoid the use of pointers. "Managed Code" is what it's called.  For the most part you shouldn't need pointers in C# but you still have the ability to use pointers in C# but its strongly discouraged.&lt;br&gt;Reply:Hi &lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointer is a powerful tool in 'C', it is used to know the memory address of a variable/identifier/value&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers are also helpful in transfer more than one values/variables/identifiers from main program/function to another function&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5515049150731554855?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5515049150731554855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-can-i-use-pointers-in-c-programming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5515049150731554855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5515049150731554855'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-can-i-use-pointers-in-c-programming.html' title='How can I use pointers in C# programming?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2557679082205643131</id><published>2009-07-14T20:14:00.001-07:00</published><updated>2009-07-14T20:14:26.604-07:00</updated><title type='text'>How can I use pointers in C#.net?</title><content type='html'>What is unsafe mode?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How can I use pointers in C#.net?&lt;br&gt;You can use pointers just like in C++ although it is use is rare( perhaps only for dealing with older API's with Win32).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You can reference memory directly, add addresses, pass by reference etc.  &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;All operations with pointers need to be within unsafe mode blocks.  Pointer operations are dangerous because you can modify or delete memory of other variable/space, for this the compiler requires you to mark areas where you use them as unsafe.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The best explanation you can find in MSDN.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2557679082205643131?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2557679082205643131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-can-i-use-pointers-in-cnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2557679082205643131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2557679082205643131'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-can-i-use-pointers-in-cnet.html' title='How can I use pointers in C#.net?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4847142861560676308</id><published>2009-07-14T20:14:00.000-07:00</published><updated>2009-07-14T20:14:14.438-07:00</updated><title type='text'>How do you use pointers in C#?</title><content type='html'>I want to have a list of items where  an item points to the next item.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How do you use pointers in C#?&lt;br&gt;You don't need a pointer to do this, only a reference (which works the same way.)  &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Define a class&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Add an instance variable nextItem of the same type as the class.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You can then tell each class what the next item in the structure is.  You can also have a prevIitem variable to get a double-linked list.&lt;br&gt;Reply:Sorry, C# doesn't support pointers.  You probably need to use the List collection.  I havn't used it so I'm not sure.  But I do know the pointers where one of the main features removed from C#.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://2survey-for-money.blogspot.com/&gt;survey for money&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4847142861560676308?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4847142861560676308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-do-you-use-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4847142861560676308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4847142861560676308'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-do-you-use-pointers-in-c.html' title='How do you use pointers in C#?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2819107215233859286</id><published>2009-07-14T20:13:00.003-07:00</published><updated>2009-07-14T20:13:55.662-07:00</updated><title type='text'>Can u tell about pointers in c++?</title><content type='html'>give an example program using class with resolution operator&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Can u tell about pointers in c++?&lt;br&gt;Pointers are a type of special variable that store the address of the ordinary data type variables rather than the variable itself. They are also of types int,char, etc to store addresses of variable of type int,char...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;eg:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;suppose intx=3;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the variable x gets stored at a memory location 1001h&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the %26amp; operator defines the address of a variable&lt;br&gt;&lt;br /&gt;&lt;br /&gt;now declare an pointer variable of type int&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *y;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;y=%26amp;x;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;here the address of x gets stored in y.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout%26lt;%26lt;y;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the result will be like 1001.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;this is the simplest way i can give you the concept of pointers but it is a huge topic to be understood completely.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;bye&lt;br&gt;Reply:http://www.google.com/search?q=c%2B%2B+p...&lt;br&gt;Reply:MyClass *obj = new MyClass();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;obj-%26gt;doit();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;How's that? -%26gt; is it.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2819107215233859286?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2819107215233859286/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-u-tell-about-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2819107215233859286'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2819107215233859286'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-u-tell-about-pointers-in-c.html' title='Can u tell about pointers in c++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6976512897016539534</id><published>2009-07-14T20:13:00.002-07:00</published><updated>2009-07-14T20:13:37.952-07:00</updated><title type='text'>I need a code for pascal's triangle in c++?</title><content type='html'>without using pointers (simple c++ lang)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the output should be:            1&lt;br&gt;&lt;br /&gt;&lt;br /&gt;                                           1        1&lt;br&gt;&lt;br /&gt;&lt;br /&gt;                                       1       2       1&lt;br&gt;&lt;br /&gt;&lt;br /&gt;                                    1     3        3      1&lt;br&gt;&lt;br /&gt;&lt;br /&gt;and follows...........&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pls help me out .....&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;I need a code for pascal's triangle in c++?&lt;br&gt;search google&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6976512897016539534?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6976512897016539534/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-need-code-for-pascals-triangle-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6976512897016539534'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6976512897016539534'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-need-code-for-pascals-triangle-in-c.html' title='I need a code for pascal&apos;s triangle in c++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6575352801786576920</id><published>2009-07-14T20:13:00.001-07:00</published><updated>2009-07-14T20:13:22.041-07:00</updated><title type='text'>Why we need pointers in C?</title><content type='html'>A pointer is the address of a variable rather than the content of it. For example try to figure out the difference between the "the third drawer" (that is, where it is located) and "the content of the third drawer" (what is inside it).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In C algorithms, there are times when we know where our variable is located, and we want to do some arithmetic or manipulation on it. In these cases, the address of the variable (a pointer to it) is more useful than the value of it. More technically, it is named call by reference. As a simple example imagine the difference between&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void inc1 (int x)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    x++ ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;and&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void inc2 (int * x)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    (*x)++ ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If we call inc1 (t), the value of t (and int variable) is copied into x, and then the value of x is incremented. But t has not changed. It’s much like I photocopy a page and I give the copy to you and you write something new on your own copy. It is the normal call-by-value function call.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;But if we call inc2(%26amp;t), the address (and not the content) of t is copied into pointer x. then the content of x is incremented. Because x has the address of t, it would mean that the content of t is incremented. It’s much like I tell you where the original page is located, and you go to the page, and write something new on it. It is call-by-reference function call.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I added this comment later. You could mean why we need pointers in C and C++ but we don't need them in languages like C# and VB?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Actually, pointers are used in VB and C#, but this use is not as transparent to the programmer as it is in C and C++. Reference as called in VB and C# is a disguised look of pointer with more limited capabilities as comapared to its capabilities in C and C++. Although pointers provide a more powerful capability, it has some potential danger and problem which could be difficult to find. Reference is quite safe, and is adequate for alomost all the situations.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Why we need pointers in C?&lt;br&gt;Pointers alows you to do low level programming efficiently from C.&lt;br&gt;Reply:Because they are alot better then using arrays. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers take up less space in memory and can be resized.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;However sometimes it just better to use a array if the list is small enough.&lt;br&gt;Reply:Because of the way programming works in general. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;When you develop an application you need to use memory resources. C being and older high level language gives you alot of low level flexibility and control. When you are using a language like C#, Java, Python and the like, they are actually using pointers for non value types.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;But C gives you the ability to allocate RAM for your application and you can set a pointer to point to that area, and use it anyway you want, as a string*, char*, int*. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;It is not a matter of needing pointers in C, pointers are needed in any good programming language, but C makes the concept of a pointer alot more apparent and gives you the choice to use value types or pointer types. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I would ask ... why would any language need complex value types like structs lol.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6575352801786576920?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6575352801786576920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-we-need-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6575352801786576920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6575352801786576920'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-we-need-pointers-in-c.html' title='Why we need pointers in C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5443372467512591662</id><published>2009-07-14T20:13:00.000-07:00</published><updated>2009-07-14T20:13:06.229-07:00</updated><title type='text'>How do pointers in C++ save memory space and how does memory work?</title><content type='html'>A space in memory holds some value of information that your program has specified it will need at some time.  So if you have already declared a space and need to reference the value of that space, you can use a pointer, instead of creating a duplicate space in memory.  Your pointer just keeps reference of the location in memory where your original information is stored.  So it saves space by not keeping the entire length of your information in two different places in memory.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How do pointers in C++ save memory space and how does memory work?&lt;br&gt;Think about a cabinet with 10 x 10 drawers. A pointer is a reference to the drawer. You will just need two digits to specify the location of any item. Now your item may be as big as you want, and with some imagination, each drawer could hold another cabinet with each one 10x10 drawers... And you get a pointer of pointer...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://survey-questions.blogspot.com/&gt;survey questions&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5443372467512591662?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5443372467512591662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-do-pointers-in-c-save-memory-space.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5443372467512591662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5443372467512591662'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-do-pointers-in-c-save-memory-space.html' title='How do pointers in C++ save memory space and how does memory work?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-3959616520360201429</id><published>2009-07-14T20:12:00.003-07:00</published><updated>2009-07-14T20:12:51.104-07:00</updated><title type='text'>NEED URGENT HELP IN C programming?</title><content type='html'>PLS tell how to calculate days between dates using structure pointers in C&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;NEED URGENT HELP IN C programming?&lt;br&gt;/* difftime example */&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;stdio.h%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;time.h%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int main ()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  time_t start,end;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  char szInput [256];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  double dif;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  time (%26amp;start);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  printf ("Please, enter your name: ");&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  gets (szInput);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  time (%26amp;end);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  dif = difftime (end,start);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  printf ("Hi %s.\n", szInput);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  printf ("It took you %.2lf seconds to type your name.\n", dif );&lt;br&gt;&lt;br /&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;  return 0;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;Reply:read in two dates.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;from the earlier date, keep adding one day, until you reach the other date.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Look at how many days you had to add.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;you got what you wanted ;)&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-3959616520360201429?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/3959616520360201429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/need-urgent-help-in-c-programming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3959616520360201429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3959616520360201429'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/need-urgent-help-in-c-programming.html' title='NEED URGENT HELP IN C programming?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-7796885881428054932</id><published>2009-07-14T20:12:00.002-07:00</published><updated>2009-07-14T20:12:35.589-07:00</updated><title type='text'>Questions relatewd to c &amp; java?</title><content type='html'>about pointers in c.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;operators in java&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Questions relatewd to c %26amp; java?&lt;br&gt;pointers are ref addresses&lt;br&gt;&lt;br /&gt;&lt;br /&gt;operators are symbols that rep a operation ie - is minus&lt;br&gt;&lt;br /&gt;&lt;br /&gt;hope this helps :)&lt;br&gt;Reply:http://www.pekiyi.150m.com&lt;br&gt;&lt;br /&gt;&lt;br /&gt;java and c language pages.&lt;br&gt;Reply:point it can store the other address of other object.&lt;br&gt;Reply:lol&lt;br&gt;Reply:Go to this site to get details of pointers in C.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.cs.cf.ac.uk/Dave/C/node10.htm...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-7796885881428054932?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/7796885881428054932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/questions-relatewd-to-c-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7796885881428054932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7796885881428054932'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/questions-relatewd-to-c-java.html' title='Questions relatewd to c &amp;amp; java?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2921488938777369610</id><published>2009-07-14T20:12:00.001-07:00</published><updated>2009-07-14T20:12:19.387-07:00</updated><title type='text'>About pointers in C...?</title><content type='html'>i am confused between these two..&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *s,p=1;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;s=%26amp;p;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;s=p;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;if s=%26amp;p points the address of p by s&lt;br&gt;&lt;br /&gt;&lt;br /&gt;how about s=p?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;what is the difference between the two?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;About pointers in C...?&lt;br&gt;s=%26amp;p&lt;br&gt;&lt;br /&gt;&lt;br /&gt;means you are assigning the address of the variable 'p' to the pointer variable 's'&lt;br&gt;&lt;br /&gt;&lt;br /&gt;and i think the second statement "s=p" will generate an error... coz you are trying to assign an int value to an int pointer.&lt;br&gt;Reply:So, think of a computer's memory as a long tape, and an address as a position on that tape. A pointer is simply an address contained in a variable that tells the computer to go to the position on the tape that's specified in the variable, got it? Now, by going %26amp;p, you're looking for where p is on that 'tape' so the computer can find it and change it's value later. When you store p into s, you're storing the contents of p into something that's supposed to only hold an address. So, when the computer tries to dereference the pointer, it ends up looking for this value that could be anywhere on the 'tape', but doesn't refer to anything specifically, which is very bad. The only time you'd see something like s=p is if both were pointers, and you want p to refer to whatever s was referring to in the first place.&lt;br&gt;Reply:s = p will store what's in p into s, in other words s will contain 1.  This is of course NOT what s is meant to have in it, and any decent C compiler should produce at least a warning message about this&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2921488938777369610?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2921488938777369610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/about-pointers-in-c_14.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2921488938777369610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2921488938777369610'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/about-pointers-in-c_14.html' title='About pointers in C...?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4465208546557884215</id><published>2009-07-14T20:12:00.000-07:00</published><updated>2009-07-14T20:12:02.334-07:00</updated><title type='text'>Assigning pointers in C++?</title><content type='html'>I do not understand the following code &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;V * v = new V;   &lt;br&gt;&lt;br /&gt;&lt;br /&gt;v-%26gt;i=8;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;System::Console::WriteLine(v-%26gt;i);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pin_ptr%26lt;V%26gt; mv = %26amp;*v; %26lt;--- what does %26amp;*v means? &lt;br&gt;&lt;br /&gt;&lt;br /&gt;mv-%26gt;i = 7;&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Assigning pointers in C++?&lt;br&gt;It appears that you took this example right from the MSDN documentation.  Basically what this code is doing is declaring a pointer to the structure 'V', then it is setting the integer member 'i' to the value of 8.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The pin_ptr%26lt;V%26gt; mv = %26amp;*v; line is what creates a "pinned" pointer to the boxed value type.  The "%26amp;*v" says to assign the address to the pinned pointer of the data which is pointed to by the pointer 'v'.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You can then change the value through the pinned pointer and your structure's member will be changed as well.&lt;br&gt;Reply:V *v=new V;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Creating a pointer object v, of a Class V.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;v-%26gt;i=8;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Assigning value 8 to member variable i of object v.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26amp;v is the address of pointer v.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://surveys4.blogspot.com/&gt;surveys&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4465208546557884215?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4465208546557884215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/assigning-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4465208546557884215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4465208546557884215'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/assigning-pointers-in-c.html' title='Assigning pointers in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4428672559206123327</id><published>2009-07-14T20:11:00.002-07:00</published><updated>2009-07-14T20:11:45.973-07:00</updated><title type='text'>Questions related to c &amp; java?</title><content type='html'>about pointers in c.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;operators in java&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Questions related to c %26amp; java?&lt;br&gt;lol&lt;br&gt;Reply:Yes, There is a concept in C called "Pointers" with which you can have variables that contain Address as their value.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;And yes, There is a concept in every programming language, which is called "Operators", that refers to those special symbols used to perform a simple task. For example, the "++" Operator (without the quotes) is used to increase the amount of an integer value by 1.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;What else do you want to know about them?&lt;br&gt;Reply:Go to this site to get full details of pointers in C.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.cs.cf.ac.uk/Dave/C/node10.htm...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Good bye.&lt;br&gt;Reply:What a silly qn?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4428672559206123327?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4428672559206123327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/questions-related-to-c-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4428672559206123327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4428672559206123327'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/questions-related-to-c-java.html' title='Questions related to c &amp;amp; java?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-506708976188767960</id><published>2009-07-14T20:11:00.001-07:00</published><updated>2009-07-14T20:11:32.525-07:00</updated><title type='text'>Is it true that pointers in C increase execution speed of the program and why?</title><content type='html'>I heard 2 arguments.First is that as pointers directly work with memory execution speed increases.Second is that ,memory handling is difficult ,so execution speed decreases.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Is it true that pointers in C increase execution speed of the program and why?&lt;br&gt;it can be true, depending on how you use them. For example if you pass a pointer to a class or function, you have ONLY passed that memory address to that class/function (and not copied the value in the variable which contains the data) which means that you have passed that variable much faster than if you were to use an actual non pointer variable or pass a variable by value.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers are fast because they contain only memory addresses so the entire contents of the variable is not copied and passed which would be much slower.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Also to answer the second part of your question, yes in large programs memory handling can be difficult, pointers are active for the scope they are placed in (provided the programmer is linking to an object ONLY, and put a deconstructor into that object), put one at the start of your program and forget to delete it, well then now you have a major problem (a memory leak). I had a programmer friend that complained about his boss always saying, son its not your memory you need to stop pretending like it is, he was fresh out of college when he got that job, and his programming skill did increase when he got it.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Honestly though, it really does depend on the way you use them as well as the algorithm you go by.&lt;br&gt;Reply:pointers unlike variables do not store the value. instead they store the memory address of the variable that stores value. when we want to get the value pointed by the pointer using *ptr then the system do not need to find the memory of the value since it is already stored by the pointer. this makes working fast. u said that execution speed increases which is true. &lt;br&gt;&lt;br /&gt;&lt;br /&gt; Also, u said that memory handling is difficult. either u have misunderstood the question is a problem. one of the solution to ur next question is that pointer deal with memory directly. so it is very difficult to debug( find error ) from a program using pointers. so this makes the program development slow and not program efficiency slow. this is other concept beyond programming and is studied in software engineering. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;  i think u have under stood the use of pointer. it has merit of fast execution but demerit of slow program development.&lt;br&gt;Reply:Yes, pointers increase the execution speed because it directly points to the location of a variable, the value can be retrieved and processed in a short span of time.&lt;br&gt;Reply:Pointers don't magically increase or decrease anything. In some instances, pointers can be detrimental. So, what is a pointer? It's a variable that contains an address to a memory location. This is important: pointers are still variables. They take memory as well. If you're pointing to a char byte, using a pointer instead of a char isn't going to increase your efficiency, and may decrease it instead.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers are useful when passing variables around in say, functions. What happens in C is that the variable is copied. So let's say you had a 100KB variable (like an array) in a struct. You don't want to pass that struct around by value, because your program would be forced to copy those 100KB. It's more efficient to refer to that memory location with a pointer, and then use that pointer to refer back to the value.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Note that you can shoot yourself in the foot with pointers. What happens if you have a memory location only known by its pointer, and then forget about the pointer (your pointer var goes out of scope, you accidentally assign another memory address, etc.)? You don't have a way to access the original memory location, and that memory sits around unused. Known as memory leaks.&lt;br&gt;Reply:Pointers increases the execution speed ,its rite...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;it is one of the advantages of pointers,thts y we r going for pointers!!&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-506708976188767960?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/506708976188767960/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/is-it-true-that-pointers-in-c-increase.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/506708976188767960'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/506708976188767960'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/is-it-true-that-pointers-in-c-increase.html' title='Is it true that pointers in C increase execution speed of the program and why?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6963775888067276961</id><published>2009-07-14T20:11:00.000-07:00</published><updated>2009-07-14T20:11:14.125-07:00</updated><title type='text'>[Pointers in C] What does this mean to an array of integers?</title><content type='html'>int a[10]={1,2,3,4,5,6,7,8,9};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *p=a;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;/* what does &lt;br&gt;&lt;br /&gt;&lt;br /&gt;p++&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*p++&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(p++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(*p)++&lt;br&gt;&lt;br /&gt;&lt;br /&gt;++*p&lt;br&gt;&lt;br /&gt;&lt;br /&gt;mean? */&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;[Pointers in C] What does this mean to an array of integers?&lt;br&gt;Arrays are the collection of similar Data Types(i.e elements) and pointers are those variables ehich holds the physical address of another variables.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now you code&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *p=a holds the address of  first element(correct would be int *p=%26amp;a)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p++ increments the address  with 2 bytes because int type acquire 2 bytes in memory&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*p++ means  increase value at address P to 1&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;++*p incremtns (i.e postincrement value at address of a)&lt;br&gt;Reply:*p=a p will have the address of the variable a&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p++ is post increment if we have a address as 1000 then the address will be incremented by 1 by post increment method.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*p++ will increment the value of the data present in the p&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(p++) first the value of p will be increment then address&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(*p)++ this will increment the address of p value&lt;br&gt;&lt;br /&gt;&lt;br /&gt;++*p this will preincrement the p value&lt;br&gt;&lt;br /&gt;&lt;br /&gt;/* */ this is treated as multi line comment&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6963775888067276961?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6963775888067276961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointers-in-c-what-does-this-mean-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6963775888067276961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6963775888067276961'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointers-in-c-what-does-this-mean-to.html' title='[Pointers in C] What does this mean to an array of integers?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4537562739760994723</id><published>2009-07-14T20:10:00.003-07:00</published><updated>2009-07-14T20:10:58.789-07:00</updated><title type='text'>Whenever I use pointers in C++  ,the whole compiler closes leaving an error dialog box saying some 32Bitsystem</title><content type='html'>It happens only with pointers and not character arrays.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;It says the NVRAM has encountered a serious error and needs to close.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Whenever I use pointers in C++  ,the whole compiler closes leaving an error dialog box saying some 32Bitsystem&lt;br&gt;make sure you delete space that you are not using, with delete[];you are not allocating/deallocation memory right, dynamic memory is pretty tough to understand. Your not going to  get it for a while. Read about it for a lil bit and get the hang of it.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://survey-monkey.blogspot.com/&gt;survey monkey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4537562739760994723?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4537562739760994723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/whenever-i-use-pointers-in-c-whole.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4537562739760994723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4537562739760994723'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/whenever-i-use-pointers-in-c-whole.html' title='Whenever I use pointers in C++  ,the whole compiler closes leaving an error dialog box saying some 32Bitsystem'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5298634207079633380</id><published>2009-07-14T20:10:00.002-07:00</published><updated>2009-07-14T20:10:43.176-07:00</updated><title type='text'>Help with Pointers in C?</title><content type='html'>A program to read in an array of names and to sort them in alphabetical order .And use a sort function that receives pointers to the functions strcmp and swap.sort in turn should call these functions via pointers&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Help with Pointers in C?&lt;br&gt;So, what's your question?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5298634207079633380?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5298634207079633380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/help-with-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5298634207079633380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5298634207079633380'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/help-with-pointers-in-c.html' title='Help with Pointers in C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-146698423508127718</id><published>2009-07-14T20:10:00.001-07:00</published><updated>2009-07-14T20:10:26.562-07:00</updated><title type='text'>What is diffrence between Function pointer &amp; pointer function?</title><content type='html'>Question Related to pointers in c.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;What is diffrence between Function pointer %26amp; pointer function?&lt;br&gt;May be, if you clearify the question more ...i would have been able to help ya.....because as far as i know, there are no such terms in C....there exist terms in C like "pointer to function" and "functions with arguments as pointers" .....so clearify it first.....&lt;br&gt;Reply:difference bet function pointer and pointer function.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;lets say "fp" as function pointer and "pf" as pointer function&lt;br&gt;&lt;br /&gt;&lt;br /&gt;"fp" is a pointer- it is pointing to some function say f(x)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;"pf" is not a pointer- rather it is a function which describes the nature of a pointer. now why should we call this function as "pf"? why cant we just call it as "function" ??-bcoz this function will ultimately act as a pointer.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-146698423508127718?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/146698423508127718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-diffrence-between-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/146698423508127718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/146698423508127718'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-diffrence-between-function.html' title='What is diffrence between Function pointer &amp;amp; pointer function?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2643501446576829516</id><published>2009-07-14T20:10:00.000-07:00</published><updated>2009-07-14T20:10:10.829-07:00</updated><title type='text'>Sorting 5 numbers using Pointers and Arrays in C++?</title><content type='html'>Hi i need to write code to sort out 5 numbers using pointers and arrays in C++. I take 5 numbers from user input. I am using a 1 dimensional array but i am not sure how i can sort them out. I have written some code below but its not sorting them out.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;i need to show the unsorted sequence and then show the sorted sequence in 3 passes.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I havent much used pointers so can someone help me out on this please?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Here is my code&lt;br&gt;&lt;br /&gt;&lt;br /&gt; #include %26lt;iostream%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int numbers [5];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int i;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *ptr=numbers;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout%26lt;%26lt;"Please enter 5 numbers to be sorted:\n\n";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for (i = 0; i %26lt; 5 ; i++ )&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cin %26gt;%26gt; numbers[i];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout%26lt;%26lt;"\nUnsorted:\n";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for (i = 0; i %26lt;= 5-1; i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout%26lt;%26lt; numbers [i]%26lt;%26lt;" ";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout%26lt;%26lt;"\n\nSorted:\n";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for (i = 0; i %26lt;= 5-1; i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout%26lt;%26lt;numbers[i]%26lt;%26lt;" ";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return 0;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Sorting 5 numbers using Pointers and Arrays in C++?&lt;br&gt;since you said it is not sorting,no wonder!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;you need to use&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the statement using &lt;br&gt;&lt;br /&gt;&lt;br /&gt;s=a[0];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(i=0;i%26lt;4;i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;if(s%26lt;a[i])&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;s=a[i];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2643501446576829516?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2643501446576829516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/sorting-5-numbers-using-pointers-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2643501446576829516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2643501446576829516'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/sorting-5-numbers-using-pointers-and.html' title='Sorting 5 numbers using Pointers and Arrays in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-8944578534719016734</id><published>2009-07-14T20:09:00.003-07:00</published><updated>2009-07-14T20:09:54.191-07:00</updated><title type='text'>I cant understand pointers and structures in C programming?</title><content type='html'>i know the basics but can anyone tell me tricks and basic things to remember for sure. i get confused when it comes to pointers and arrays and there connection and when to use *p and when to use %26amp;p and when not to. can anyone summarize the rules and common mistakes with pointers and structures in C programming.  Also string literal basics as well. Thanks. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Whateveryou can explain will definitely help!&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;I cant understand pointers and structures in C programming?&lt;br&gt;Homestar is right as far as he goes.  He uses a type called "string" which wasn't part of the ansi c language last Og checked - and quite frankly, strings, char arrays, are almost everybody's first introduction to the finer points of pointers vs the object to which the pointer refers.  Og like to suggest picking up a copy of K%26amp;R (because it's thin and pretty easy to understand) and maybe suggest you throw references into the mix (references keep you from making 'stupid' mistakes with pointers - things like freeing memory that you shouldn't).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Everybody write this once:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *myname = "Og";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char[]  firstName = "Og";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char[2]  alsoFirstName;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;strncpy( alsoFirstName, myname, strlen(myname) );&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf( "myname:  %s\n", myname );  //  s.b. ok&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf( "firstName:  %s\n", firstName );  // also ok&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf( "alsoFirstName:  %s\n", alsoFirstName );  // oops!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Why does that third one fail?  Because the array doesn't actually have space allocated for two characters plus one terminator (\0) symbol.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Note the different forms of initializing a string pointer, as well (all three variables can act like a char const*).  In the first case the string (the two letters 'O', 'g' and the terminator) are kept in some data segment that never changes.  In the second and third examples, the string is stored on the stack.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Anyway, this is pretty deep topic.  Maybe e-mail work better.  Barring any real concrete examples just remember:  const and %26amp; (reference type) are your friends.&lt;br&gt;Reply:Structures are a collection variables under a name.Each variable within the structure can be accessed using the '.' mark.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;An example would be this&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct profile{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;string name;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int age;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}person1;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;As you can see i have created a new structure called Profile and a new instance of this structure called person1.Now if i want to store anything about person1 i would do it like this.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;person1.name = "Joe Schmoe"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;As you can see i use the '.' mark to access the variables within the structure.Hope that helps you.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;As for arrays,they are also a collection of variables,however they all have one datatype.To declare an array i do so.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int age[2]&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The number within the square brackets indicates i want two integers named age.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;To access each part of this array you also use the square brackets.However you must start counting from 0 when you want to access an array.Below is an example of me initializing both these integers.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;age[0] = 65;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;age[1] = 23;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I hope you understood me clearly ^_^.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Im not very good with pointers so bare with me.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A pointer points to a space in memory,a pointer will store this place in memory as an address.Declaring a pointer is as easy as declaring any other datatype,but you must place an asterisk (*) after the datatype.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;e.g int* my_pointer;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now to use this pointer we must assign it the address of another variable.For example say we had a variable called "age".To point to this variable in memory we must precede its name with the Ampersand sign (%26amp;).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;e.g   my_pointer = %26amp;age ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now if we were to output this pointer,it would give us the memory address of the variable age.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;EDIT:Sorry i code in c++ i forgot to not use strings,however you should understand how structures work :)&lt;br&gt;Reply:OK... three questions in one.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Firstly pointers. Pointers aren't variables - but they do point to them. Pointers are defined using a * between the type and the variable, for example:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int* pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The latter makes more sense, as you're defining a pointer to an integer, and not an integer. However, it can cause confusion if you define normal integers on the same line, for example:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *pointer,variable&lt;br&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int* pointer,variable&lt;br&gt;&lt;br /&gt;&lt;br /&gt;both define pointer as a pointer to an integer, and variable to an integer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers let you have multiple instances of the same variable. For example:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int i=3;   /* initialise an integer */&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *p;  /* create an integer pointer */&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p=%26amp;i;  /* and point it to the address of i */&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*p=5;  /* set value of integer pointed to by p, to 5&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%d %d",i,*p); /* print out value of both variables */&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Not too useful, since I could have just used i and not the pointer? True. However, this comes into its own with allocated blocks of memory and (more simply) arrays.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;See http://www.cprogramming.com/tutorial/c/l... for more details.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Next, structures. Basically, a group of variables tied together. For example, you could have an address-book with a structure 'addressBookEntry' for each entry, and within the structure you could have a name, address, phone-number, etc - but which could be referenced by a single variable name (or array) so that all the associated data is kept together within the same structure. Like a box.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I'll point you at the same site, next chapter for more info.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.cprogramming.com/tutorial/c/l...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Finally, string literals. These are defined within source-code as the value of a quoted string. For example:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;"This is a string literal"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Again, more info at the same site:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.cprogramming.com/tutorial/c/l...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://10online-survey.blogspot.com/&gt;online survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-8944578534719016734?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/8944578534719016734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-cant-understand-pointers-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8944578534719016734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8944578534719016734'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-cant-understand-pointers-and.html' title='I cant understand pointers and structures in C programming?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5238996425599126746</id><published>2009-07-14T20:09:00.002-07:00</published><updated>2009-07-14T20:09:38.137-07:00</updated><title type='text'>Polymorphism in C++?</title><content type='html'>Does C++ require that pointers be used to use Polymorphism in C++?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Why I ask:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I created a simple class Vehicle which has nothing except a member function called "showType()" which displays "I am a vehicle".   I then created a subclass of Vehicle, Car, with a function called "showType()" which displays "I am a car".  The function showType() is marked as virtual in the base class.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If I write the following code:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Vehicle test[10] ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Car c ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;test[0] = c ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;test[0].showType() ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The output "I am a Vehicle is produced" -- clearly no polymorphism.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;However, if I change to using pointers:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Vehicle* test[10] ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Car c ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;test[0] = %26amp;c ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;test[0]-%26gt;showType() ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This shows the result I expect -- "I am a car".  Does C++ only support Polymorphism with pointers?  In some sense this seems to be logical since Polymorphism is a runtime feature, however I was a little disappointed that it couldn't distinguish in the non-pointer case -- I was hoping for a container type effect similar to Java.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Polymorphism in C++?&lt;br&gt;C++ always uses pointers to work with polymorphism and other OOP subjects.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5238996425599126746?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5238996425599126746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/polymorphism-in-c_14.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5238996425599126746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5238996425599126746'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/polymorphism-in-c_14.html' title='Polymorphism in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4528346963740998950</id><published>2009-07-14T20:09:00.001-07:00</published><updated>2009-07-14T20:09:21.933-07:00</updated><title type='text'>Polymorphism in C++?</title><content type='html'>Does C++ require that pointers be used to use Polymorphism in C++?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Why I ask:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I created a simple class Vehicle which has nothing except a member function called "showType()" which displays "I am a vehicle". I then created a subclass of Vehicle, Car, with a function called "showType()" which displays "I am a car". The function showType() is marked as virtual in the base class.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If I write the following code:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Vehicle test[10] ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Car c ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;test[0] = c ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;test[0].showType() ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The output "I am a Vehicle is produced" -- clearly no polymorphism.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;However, if I change to using pointers:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Vehicle* test[10] ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Car c ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;test[0] = %26amp;c ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;test[0]-%26gt;showType() ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This shows the result I expect -- "I am a car". Does C++ only support Polymorphism with pointers? In some sense this seems to be logical since Polymorphism is a runtime feature, however I was a little disappointed that it couldn't distinguish in the non-pointer case -- I was hoping for a container type effect similar to Java.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Polymorphism in C++?&lt;br&gt;The difference, Sharpie, between&lt;br&gt;&lt;br /&gt;&lt;br /&gt;test[0] = c ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;and&lt;br&gt;&lt;br /&gt;&lt;br /&gt;test[0] = %26amp;c ;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;is that in the first case you are copying an instance of something to a Vehicle. In that event, all of c that is a Vehicle will be copied to test[0], and test[0] will have none of the Carness. C will remain a Car and test[0] will remain only a Vehicle.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;However, %26amp;c is a pointer, so regardless of type it is cast to, it will always be a pointer to an instance of a Car, even if it is cast to a Vehicle pointer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;As a rule of thumb, yes, you will need to deal only with pointers if you are going to make polymorphism work. However, according to the technical definition, a reference is not a pointer, but as far as the machine code is concerned, it is, so this&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Vehicle %26amp;v = c;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;v.showType();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;would also reveal it to be a Car.&lt;br&gt;Reply:That is the correct behavior in both cases.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You will only see polymorphic behavior with pointers and references.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;My java is pretty rusty but I don't recall that it is different in this respect.  I suspect you were storing references (whether or not you realized it) in the containers.&lt;br&gt;Reply:Its supported!!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I also am studying programming and do not know but here:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.google.com/search?hl=en%26amp;q=pol...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4528346963740998950?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4528346963740998950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/polymorphism-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4528346963740998950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4528346963740998950'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/polymorphism-in-c.html' title='Polymorphism in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-8517589171471074494</id><published>2009-07-14T20:09:00.000-07:00</published><updated>2009-07-14T20:09:06.476-07:00</updated><title type='text'>Im having trying to understand the concept of pointers in c++?</title><content type='html'>I understand that they point to the location of the integer but why would u use a pointer. It makes no sense to me. Many program use them but why, Thnx&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Im having trying to understand the concept of pointers in c++?&lt;br&gt;Pointers are used alot in data structures (as well as many other things).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For example, you can have what is known as a linked list.  This is a list that contains items that link to the next item in the list via pointer.  This allows you alot of flexibilty and speed in "moving around the data" logically because you simply have to change the pointer, not shift all the data around in memory.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This is an example of a few items in a linked list:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Name: NodeA&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Data:  A&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Next: Address of NodeB&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Name: NodeB&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Data:  B&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Next: Address of NodeC&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Name: NodeC&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Data: C&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Next: Address of NodeD&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;etc.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now if you wanted to delete node b, you would just have to change the next on node a to node c, rather than having to delete the data for node b and then move all items after it down a section to take its place.&lt;br&gt;Reply:Pointers are used for several reasons.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Normally you would use a pointer to point to an object.  That object may have different characteristics based on something in the record.  In one instance it may point to car object and later a bus object.  It can be easier to handle using pointers.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers can also be used point to an parameter to a function call.  This allows the function to operate on the real object rather than a copy.  Passing copies back and forth can be wasteful in both time and space.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Text me if I haven't helped.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-8517589171471074494?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/8517589171471074494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/im-having-trying-to-understand-concept.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8517589171471074494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8517589171471074494'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/im-having-trying-to-understand-concept.html' title='Im having trying to understand the concept of pointers in c++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2966729556648045388</id><published>2009-07-14T20:08:00.003-07:00</published><updated>2009-07-14T20:08:52.075-07:00</updated><title type='text'>Need help with pointers in C?</title><content type='html'>How would I write this and why isn't it working?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I have a pointer pointing to the first character in a string. I want to store this string to the first entry in a two-dimensional array called "paths". Why isn't my loop storing the string?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char* token;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;while (token != NULL)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;          paths[ 0 ][ j ] = %26amp;token;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;          token++;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;          j++;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Need help with pointers in C?&lt;br&gt;You didn't assign token to anything.  Also, you appear to be confusing address %26amp; with object pointed to *.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char szMystring[] = "I have a problem.";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char* token;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char paths[2][64];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;token = %26amp;szMystring[0];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int j = 0;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;while (*token != 0)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;paths[ 0 ][ j ] = *token;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;token++;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;j++;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://salary-survey2.blogspot.com/&gt;salary survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2966729556648045388?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2966729556648045388/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/need-help-with-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2966729556648045388'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2966729556648045388'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/need-help-with-pointers-in-c.html' title='Need help with pointers in C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-878918278765967486</id><published>2009-07-14T20:08:00.002-07:00</published><updated>2009-07-14T20:08:35.430-07:00</updated><title type='text'>About pointers in c with example?</title><content type='html'>i need a daily e mail from u about programming in c with example&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;About pointers in c with example?&lt;br&gt;Yeah - right! I'm going to e-mail you DAILY with examples?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Try using the Yahoo search engine to find them. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;As a search, try this:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://search.yahoo.com/search?p=%22C%22...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-878918278765967486?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/878918278765967486/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/about-pointers-in-c-with-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/878918278765967486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/878918278765967486'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/about-pointers-in-c-with-example.html' title='About pointers in c with example?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4615514843796566937</id><published>2009-07-14T20:08:00.001-07:00</published><updated>2009-07-14T20:08:17.667-07:00</updated><title type='text'>Incrementing  array of pointers in C?</title><content type='html'>Can someone explain to me why postfix and prefix  increment of pointer to pointer works differently, please?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;My code is as follow:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;stdio.h%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;     char* s[ ] = {"hello", "how", "are", "you"};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;     char ** p;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;     &lt;br&gt;&lt;br /&gt;&lt;br /&gt;     p= s;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;     printf("%s ", *p);          //print out hello expected&lt;br&gt;&lt;br /&gt;&lt;br /&gt;     *p++;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;     printf("%s", *p);           //print out how as expected&lt;br&gt;&lt;br /&gt;&lt;br /&gt;     ++*p;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;     printf("%s", *p);           //print out "ow". expecting "are"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;My question is if I *p++,  p points to next string in the array. But when I do *p++, it points to the next word of the string it is pointing to. Why??&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Thank you very much in advance.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Incrementing  array of pointers in C?&lt;br&gt;The problem does not lie in preincrement or postincrement&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The problem lies in operator precedence.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p=s =%26gt; *p = s[0]&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now *p++ resolves to *(p++) = s[1]&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Then ++*p resolves to ++(*p) = s[1][1]&lt;br&gt;&lt;br /&gt;&lt;br /&gt;What I think you needed was *(++p) = s[2]&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Its always advised to use brackets to ensure that you clearly understand what precedence you are expecting.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4615514843796566937?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4615514843796566937/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/incrementing-array-of-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4615514843796566937'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4615514843796566937'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/incrementing-array-of-pointers-in-c.html' title='Incrementing  array of pointers in C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-3704536435424159954</id><published>2009-07-14T20:08:00.000-07:00</published><updated>2009-07-14T20:08:06.374-07:00</updated><title type='text'>Pointers in C++?</title><content type='html'>For instance, in C++:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *x;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *y = new int;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*y=16;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;x=y;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;delete y;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout%26lt;%26lt;x%26lt;%26lt;endl;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;what will be printed out (nothing or 16)? and why? thanks a lot&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Pointers in C++?&lt;br&gt;Asuming that the cout line is cout %26lt;%26lt; *x %26lt;%26lt; endl:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;======================================&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The right answer to this question is: undefined. If the particluar memory space still contains 16, it may print 16. But if any other program has now snacthed it and used it for some other purpose, it may be that value. It may be garbage, it may crash, it may punch you on the nose with a hand coming out of the monitor.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The right advice for people who try such things: use C++ the right way. Respect the flexibility that pointers allow you to have. Do not try to access memory that you have not been assigned or you have deleted. What you are trying to do is interacting with a dead person. The ghost might get you!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;And yes, I forgot to mention that some compilers do set the value to zero, as one of the answers above states it will be zero. That answer is strictly compiler specific. And such a compiler is too gentlemanly I would say. You should try to write code in such a way that most if not all good compilers run it smoothly.&lt;br&gt;Reply:0 is printed due to null pointer assignment&lt;br&gt;Reply:The answer is 0&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If you comment out the line&lt;br&gt;&lt;br /&gt;&lt;br /&gt;delete y;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;then the answer is 16.&lt;br&gt;Reply:The correct answer is it's undefined, because you're accessing memory that's been deallocated.&lt;br&gt;Reply:It will print out the memory location of y because you assigned the y to int x, but y is empty.&lt;br&gt;Reply:it wont print anything,&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the results will pretty much just be nothing,&lt;br&gt;&lt;br /&gt;&lt;br /&gt;you should download dev-c++&lt;br&gt;Reply:I compiled your code and ran it and I got an outcome of: 0x32460&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I'm not sure why this is because I'm new to C++ (and programming in general).&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-3704536435424159954?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/3704536435424159954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointers-in-c_14.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3704536435424159954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3704536435424159954'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointers-in-c_14.html' title='Pointers in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-845318196906676947</id><published>2009-07-14T20:07:00.003-07:00</published><updated>2009-07-14T20:07:50.119-07:00</updated><title type='text'>Pointers in C language?</title><content type='html'>What are two ways i could assign the  address of an array element [3][2] to a pointer?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Pointers in C language?&lt;br&gt;like this&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *p;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p = %26amp;array[3][2];&lt;br&gt;Reply:int *ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr = %26amp;array[3][2];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;and&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *ptr1,*ptr2;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr1 = %26amp;array[3][2];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr2 = ptr1;&lt;br&gt;Reply:int* p; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;p = %26amp;a[3][2];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int* q;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;q = a[3] + 2;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In the first one, the "%26amp;" just means "the address of".&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In the second one, because it's a 2-dimensional array a[3] just gives me the address of the beginning of the 4th row (row 1 would be a[0]), which I just add 2 to in order to advance the address 2 places further down the row.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://surveys4.blogspot.com/&gt;surveys&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-845318196906676947?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/845318196906676947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointers-in-c-language.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/845318196906676947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/845318196906676947'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointers-in-c-language.html' title='Pointers in C language?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-7030736250215283204</id><published>2009-07-14T20:07:00.002-07:00</published><updated>2009-07-14T20:07:31.546-07:00</updated><title type='text'>What is wild pointer , Null Pointer,Void pointer &amp; Dangling Pointer? How can we distinguish between them?</title><content type='html'>Related To Pointer  in c&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;What is wild pointer , Null Pointer,Void pointer %26amp; Dangling Pointer? How can we distinguish between them?&lt;br&gt;In computer science, a pointer is a programming language datatype whose value refers directly to ("points to") another value stored elsewhere in the computer memory using its address. Obtaining the value that a pointer refers to is called dereferencing the pointer. A pointer is a simple implementation of the general reference datatype (although it is quite different from the facility referred to as a reference in C++).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;                 Null Pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A null pointer has a reserved value, often but not necessarily the value zero, indicating that it refers to no object. Null pointers are used routinely, particularly in C and C++, to represent exceptional conditions such as the lack of a successor to the last element of a linked list, while maintaining a consistent structure for the list nodes. This use of null pointers can be compared to the use of null values in relational databases and to the "Nothing" value in the "Maybe" monad. In C, each pointer type has its own null value, and sometimes they have different representations.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Because it refers to nothing, an attempt to dereference a null pointer can cause a run-time error that usually terminates the program immediately (in the case of C, often with a segmentation fault, since the address literally corresponding to the null pointer will likely not be allocated to the running program). In Java, access to a null reference triggers a Java.lang.NullPointerException, which can be caught (but a common practice is to attempt to ensure such exceptions never occur). In safe languages a possibly null pointer can be replaced with a tagged union which enforces explicit handling of the exceptional case; in fact, a possibly-null pointer can be seen as a tagged union with a computed tag.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A null pointer should not be confused with an uninitialized pointer: a null pointer is guaranteed to compare unequal to a pointer to any object or function, whereas an uninitialized pointer might have any value. Two separate null pointers are guaranteed to compare equal.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;                           Void Pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt; a void pointer (void *), which indicates that it is a pointer to a region of unknown data type. This pointer is typically cast to a more specific pointer type by the programmer before being used.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;malloc returns a void pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;                               Dangling Pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A reference that doesn't actually lead anywhere. In C and some other languages, a pointer that doesn't actually point at anything valid. Usually this happens because it formerly pointed to something that has moved or disappeared, e.g. a heap-allocated block which has been freed and reused. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Hope this will satisfy you.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;R. Nag MS (Comp. Sc)&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-7030736250215283204?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/7030736250215283204/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-wild-pointer-null-pointervoid.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7030736250215283204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7030736250215283204'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-wild-pointer-null-pointervoid.html' title='What is wild pointer , Null Pointer,Void pointer &amp;amp; Dangling Pointer? How can we distinguish between them?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-843310699089208</id><published>2009-07-14T20:07:00.001-07:00</published><updated>2009-07-14T20:07:15.164-07:00</updated><title type='text'>How pointers make a C program faster?</title><content type='html'>can use of pointers make a C program faster?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How pointers make a C program faster?&lt;br&gt;They allow direct memory manipulation.&lt;br&gt;Reply:Yes, using pointers will help you to control computer memory&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For tutorials click here.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.dreamincode.net/forums/showto...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-843310699089208?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/843310699089208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-pointers-make-c-program-faster.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/843310699089208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/843310699089208'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-pointers-make-c-program-faster.html' title='How pointers make a C program faster?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-8718245886784397878</id><published>2009-07-14T20:07:00.000-07:00</published><updated>2009-07-14T20:07:00.890-07:00</updated><title type='text'>What u mean by pointers(c-prgraming)?</title><content type='html'>Pointers literally mean what they say, they point to a memory location. Say for instance you have stored a variable x in a memory location. y is a pointer to the location of x. All it says is that I point to x and x is at this location and has a certain value. Pointer programming is very useful and is extensively used for several complicated problems. Pointers have a constant size of 4 bytes and can be used to point to variables of any type: char, int, long, etc.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;What u mean by pointers(c-prgraming)?&lt;br&gt;They are special variables which hold memory address of another variable&lt;br&gt;&lt;br /&gt;&lt;br /&gt;a pointer is a separate variable that refers to another location in memory&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-8718245886784397878?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/8718245886784397878/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-u-mean-by-pointersc-prgraming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8718245886784397878'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8718245886784397878'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-u-mean-by-pointersc-prgraming.html' title='What u mean by pointers(c-prgraming)?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4880085603648571259</id><published>2009-07-14T20:06:00.002-07:00</published><updated>2009-07-14T20:06:42.551-07:00</updated><title type='text'>C++ programing this is part of my study guide and im not sure if my answers are right could you help me out?</title><content type='html'>1.The arguments in a function call must match the arguments in&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the function's header&lt;br&gt;&lt;br /&gt;&lt;br /&gt;a)only when the function call is in a different file from the function body.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;b)in number, order, and variable name.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;c)in number and order only.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;d)in number, order, and type.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;e)They don't have to match the header, only the function prototype.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;2.To use I/O redirection to read from a file you need to:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;a.declare a file variable in your program and openit&lt;br&gt;&lt;br /&gt;&lt;br /&gt;b.use the full path name with cin (a:\file1.dat.cin %26gt;%26gt;)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;c.run your program from dos and add the file to be read from with the correct operator ( myprog %26lt; file1.dat)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;d.any of the above will work&lt;br&gt;&lt;br /&gt;&lt;br /&gt;3.If you try to explicitly open an ifstream or ofstream file, how can you tell if the file opened successfully?&lt;br&gt;&lt;br /&gt;&lt;br /&gt; a.use the fail() function (method)&lt;br&gt;&lt;br /&gt;&lt;br /&gt; b.a return code of 1 indicates success&lt;br&gt;&lt;br /&gt;&lt;br /&gt; c.a pointer to a buffer that will receive data will be null if it fails&lt;br&gt;&lt;br /&gt;&lt;br /&gt; d.there is no way to tell  other than to try to do input of output&lt;br&gt;&lt;br /&gt;&lt;br /&gt; e.a return code of 0 for success&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C++ programing this is part of my study guide and im not sure if my answers are right could you help me out?&lt;br&gt;1-d&lt;br&gt;&lt;br /&gt;&lt;br /&gt;2-b&lt;br&gt;&lt;br /&gt;&lt;br /&gt;3-c&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Please select best answer if all are correct&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://survey-monkey.blogspot.com/&gt;survey monkey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4880085603648571259?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4880085603648571259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-programing-this-is-part-of-my-study.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4880085603648571259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4880085603648571259'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-programing-this-is-part-of-my-study.html' title='C++ programing this is part of my study guide and im not sure if my answers are right could you help me out?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6902217866514958445</id><published>2009-07-14T20:06:00.001-07:00</published><updated>2009-07-14T20:06:26.890-07:00</updated><title type='text'>C++ and pointers? I wrote a few lines to help me understand this..please explain...easy question!?</title><content type='html'>#include %26lt;iostream%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int main(){&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int* x;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int y = 4;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;x = %26amp;y; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//is it correct to say something like x is a memory address and by putting %26amp;y, the compiler reads it as "take x, which is a variable that stores strictly a memory address and store the  memory address which contains the content of the variable y"??&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;std::cout %26lt;%26lt; *x %26lt;%26lt; '\n';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *z = x;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;++*z;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//also for the above, int *z = x;  is setting a variable z which strictly stores the address, to the address of x (which may or may contain data) and the ++*z is read by a compiler as (increment the value of the memory address z)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;std::cout %26lt;%26lt; *z %26lt;%26lt; '\n';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return 0;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Once you declare a pointer such as int *ptr the rest of the block referring to ptr refers to the mem address and *ptr refers to the data at that address right?...where does %26amp;ptr fit into the picture?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Is what I am saying correct??? In your own words what does &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *ptr&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr &lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26amp;ptr &lt;br&gt;&lt;br /&gt;&lt;br /&gt;*ptr&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;all referring to?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Thanks!!&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C++ and pointers? I wrote a few lines to help me understand this..please explain...easy question!?&lt;br&gt;See if this makes some sense to you.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If I say;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int y = 5;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I created the variable y (at this point you have no idea where in memory this variable is) and it put the 5 in that location.  So refering to y in a program is now like saying get what is in y (the 5) and do something with it.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;std::cout %26lt;%26lt; y %26lt;%26lt; \n;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now say you happen to know that the memory location used for y is 1000.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If I said:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *x = 1000;  // Note the compiler is probably going to complain about this because 1000 isn't a proper integer pointer, but this is just to get the idea.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Is creating the variable x.  And putting the memory location 1000 in it.  Now I want to not what is in x, but what is at the location 1000, so I "dereference the pointer x".  Which is given by *x, or in other words give me the value of the integer at that location that is stored in x.  So in this case since x is pointing the the same location as y, *x will give me 5.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;std::cout %26lt;%26lt; *x %26lt;%26lt; '\n";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now for %26amp;y.  This will give me that address (memory location) of where y is storing its value.  So without knowing where y is storing its value I can do it like this:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *x = %26amp;y;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;That creates x and sets it to the memory location where y is storing its interger value.  And is the proper way to set the pointer x because I'm setting the integer pointer x to the memory location where y is storing its value.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Note that even though the syntax says;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *x;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*x&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;These are actually not the same.  The *x is just the way to declare a pointer to an integer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Where as *x is tell it to given you the integer value from where x is pointing to.&lt;br&gt;Reply:int *ptr      /*this delcairs a pointer of type int. Which means that the ptr can point to any data type flag as an int type. eg int or int[ ]*/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr = the address of something. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26amp;ptr = this is the address of the pointer ptr , in terms of memory storage&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*ptr = this "dereferences" the pointer and returns the contence of the memory address contain in ptr. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for example.....&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int* pointer; // at this point the pointer is swinging... if you deref it you will segfault this is because it contains a random address some where on your computer. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int number = 100;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// now we want to store the the memory address of "number" so we say. "%26amp;" mean "the address of"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pointer = %26amp;number&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// now we want to out put the number that the point points to.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;so we dereference the pointer... which mean that we look at the contence of the pointer and convert it to an address, then we move to the address location and return that data to the calling line. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout %26lt;%26lt; *pointer %26lt;%26lt; endl;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// if we wish to alter the data begin referenced we can do this&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// "*" means dereference. or n simple terms move to down the pointer to the thing being pointed at.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(*pointer)++;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//or&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*pointer = *pointer + 1; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;anyway i hope this helps&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6902217866514958445?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6902217866514958445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-and-pointers-i-wrote-few-lines-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6902217866514958445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6902217866514958445'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-and-pointers-i-wrote-few-lines-to.html' title='C++ and pointers? I wrote a few lines to help me understand this..please explain...easy question!?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5263901490337827789</id><published>2009-07-14T20:06:00.000-07:00</published><updated>2009-07-14T20:06:10.712-07:00</updated><title type='text'>Again c++ and pointers ...?</title><content type='html'>I try to learn the pointers and in the same time to create a GTA-SA trainer but i'm having problems ...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;i use this code :&lt;br&gt;&lt;br /&gt;&lt;br /&gt;"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int main ()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *pointer;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pointer = reinterpret_cast%26lt;int*%26gt;(0xB7CE50);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*pointer = 100;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;getchar();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;But i get this:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;"Unhandled exception at 0x004113c8 in memory.exe: 0xC0000005: Access violation writing location 0x00b7ce50."&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I also tried to do pointer = 0xB7CE50; but won't compile,can not convert from int to int* .&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So what now?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Can anyone give me a good and working example?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;PS:You can use inline ASM!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Thanks!!!&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Again c++ and pointers ...?&lt;br&gt;The reason this is throwing an exception is because the memory location you are trying to write to 0x00B7CE50 is protected by the operating system.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The proper way to get memory for a pointer is to utilize the c++ opperator 'new'&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;try this:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int* pointer;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pointer = new int();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// in straight C this would be pointer = (int*)malloc(sizeof(int));&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*pointer = 100;&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5263901490337827789?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5263901490337827789/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/again-c-and-pointers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5263901490337827789'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5263901490337827789'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/again-c-and-pointers.html' title='Again c++ and pointers ...?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6995109590004392849</id><published>2009-07-14T20:05:00.003-07:00</published><updated>2009-07-14T20:05:54.234-07:00</updated><title type='text'>What are examples of output statements for arrays and pointers in C++?</title><content type='html'>I am trying to learn pointers and arrays for C++ class. I am using MS Visual Studio 2005. I can initialize, I can set it. But I can't get it to print to the screen. Any beginner help is welcomed!&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;What are examples of output statements for arrays and pointers in C++?&lt;br&gt;You had not said whether you want to print address your pointer points to or data placed at this address.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In plain C:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int n = 0;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *p = %26amp;n;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf( "At address %p we have value %d\n", p, *p );&lt;br&gt;Reply:#include %26lt;iostream%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int arr[5] : {1,5,3,9,4};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout %26lt;%26lt; arr[4]; //should print "9"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return 0;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;Reply:use a for loop&lt;br&gt;&lt;br /&gt;&lt;br /&gt;like for(int i=0;i%26lt; 100;i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout %26lt;%26lt; a[i] %26lt;%26lt; endl;&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6995109590004392849?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6995109590004392849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-are-examples-of-output-statements.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6995109590004392849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6995109590004392849'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-are-examples-of-output-statements.html' title='What are examples of output statements for arrays and pointers in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-3451998287744907999</id><published>2009-07-14T20:05:00.002-07:00</published><updated>2009-07-14T20:05:38.467-07:00</updated><title type='text'>What is the necessity of pointers in C language explicitly or implicitly?</title><content type='html'>interview question asked in infosys and can't we have C language without the pointers??&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;What is the necessity of pointers in C language explicitly or implicitly?&lt;br&gt;Pointers are needed for:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Reference parameters in functions (call by reference)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For functions with variable arguments (like printf)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Dynamic data structures (like trees, lists and dynamically allocated arrays)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;As function pointers (callbacks) used mainly in libraries for code reuse (see qsort function)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For system programing (low level I/O).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Without pointers C would be something like the primitive basics used in home computers.  &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;There are alternatives to pointers called references, but those are only used in modern langauges like C# or Java.&lt;br&gt;Reply:Possibility of both are exist because you can create reference of pointer as void (pointer i.e., void *) then explicitly give the address of any type... &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;in contrast of implicitly you can create any type data pointer and which will hold the address of related type...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;so it depends on your need. I hope it will help full for you.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;if any question in more precise way..&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;bye&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://10online-survey.blogspot.com/&gt;online survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-3451998287744907999?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/3451998287744907999/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-necessity-of-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3451998287744907999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3451998287744907999'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-necessity-of-pointers-in-c.html' title='What is the necessity of pointers in C language explicitly or implicitly?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4718164565131479106</id><published>2009-07-14T20:05:00.001-07:00</published><updated>2009-07-14T20:05:22.652-07:00</updated><title type='text'>Sample programs of POINTERS in C.?</title><content type='html'>sample programs of POINTERS in C.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Sample programs of POINTERS in C.?&lt;br&gt;#include %26lt;iostream%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int main(int argc, char **argv)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   cout %26lt;%26lt; "The name of this program is: " %26lt;%26lt; *argv %26lt;%26lt; endl;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;Reply:yes&lt;br&gt;Reply:AND !!&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4718164565131479106?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4718164565131479106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/sample-programs-of-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4718164565131479106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4718164565131479106'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/sample-programs-of-pointers-in-c.html' title='Sample programs of POINTERS in C.?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2327188861231625535</id><published>2009-07-14T20:05:00.000-07:00</published><updated>2009-07-14T20:05:06.858-07:00</updated><title type='text'>Tell me about pointers in c.and some exaples and use of ponters?</title><content type='html'>i am a student. i am doing bca from ignou in this course i am reading pointers in c. so there any one who can help in understanding the pointers with some examples. or you can tell me about sites that can help in doing this course succsessfully or any one that done or purcuing bca from ignou contact me&lt;br&gt;&lt;br /&gt;&lt;br /&gt;warm regards &lt;br&gt;&lt;br /&gt;&lt;br /&gt;yogesh tyagi&lt;br&gt;&lt;br /&gt;&lt;br /&gt;gurgaon(122001)&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Tell me about pointers in c.and some exaples and use of ponters?&lt;br&gt;buy "understanding pointers in c" by 'Yashwant Kanetkar' dude................&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2327188861231625535?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2327188861231625535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/tell-me-about-pointers-in-cand-some.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2327188861231625535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2327188861231625535'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/tell-me-about-pointers-in-cand-some.html' title='Tell me about pointers in c.and some exaples and use of ponters?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-1353246289358237090</id><published>2009-07-14T20:04:00.003-07:00</published><updated>2009-07-14T20:04:52.828-07:00</updated><title type='text'>How can pointers in C++ be usefull in C++?</title><content type='html'>i'm reading about pointers in C++ and they dont really seam to be worthwhile or am i missing something?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How can pointers in C++ be usefull in C++?&lt;br&gt;Pointers provide a lot of power within a C++ (or C) application.  You can allocate memory in one spot and have it persist for as long as you need it, as long as you delete them memory allocation before the application exits.  This persistence of memory provides for a lot of flexibility because the memory can be accessed anywhere from inside the application as long as you provide the pointer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;There is a lot you can do with pointers once you fully understand what you're dealing with.  Just like the Force, though, pointers have both a light and dark side, and the dark side of pointers can lead you to crashing applications, crashing the system, or worse....&lt;br&gt;Reply:You're kidding, right? &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers are desirable (at times) because they allow you in, an OO architecture, to put a value or value array into memory exactly once, instead of making repeated copies of it into memory as you pass the value through your classes and methods.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;But pointers move from desirable to absolutely necessary when you try and use the operating system's APIs, or the graphical subsystem's. Most API calls in, well, just about any operating system will require you to pass/retrieve pointers. You can't expect to write much more than "Hello world!" without pointers...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-1353246289358237090?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/1353246289358237090/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-can-pointers-in-c-be-usefull-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1353246289358237090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1353246289358237090'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-can-pointers-in-c-be-usefull-in-c.html' title='How can pointers in C++ be usefull in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6989241910772038014</id><published>2009-07-14T20:04:00.002-07:00</published><updated>2009-07-14T20:04:34.613-07:00</updated><title type='text'>Structures and pointers in C#. How can I implement them?</title><content type='html'>Hi!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I want to implement the foloowing in C#:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct mytree&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char name[80]; // information&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int noChildren; // number of children&lt;br&gt;&lt;br /&gt;&lt;br /&gt;mytree *children; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Is it possible? How?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Or can I do somethink like that, using C# types?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Please help!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I don't want to use pointers! (dangerous in C#)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Thanks!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;PS: if you need more details, please try to imagine that&lt;br&gt;&lt;br /&gt;&lt;br /&gt;a run "tree" command from Dos Prompt (cmd.exe) and&lt;br&gt;&lt;br /&gt;&lt;br /&gt;a have to load all the folders in memory, in a structure.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Structures and pointers in C#. How can I implement them?&lt;br&gt;In C#,  I would convert this to a class so that you could make use of the Generic List%26lt;T%26gt;.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    class MyTreeNode&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;        public string Name;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;        public List%26lt;MyTreeNode%26gt; MyChildren = new List%26lt;MyTreeNode%26gt;();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Here is an example of how its used:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    class Program&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    { &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;        static void Main(string[] args)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;        {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            MyTreeNode node = new MyTreeNode();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            MyTreeNode child = new MyTreeNode();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            node.Name = "root";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            child.Name = "child";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            node.MyChildren.Add(child);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            MyTreeNode childOfChild = new MyTreeNode();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            childOfChild.Name = "childOfChild";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            child.MyChildren.Add(childOfChild);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            foreach (MyTreeNode nodeChild in node.MyChildren)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;                //access the children of root&lt;br&gt;&lt;br /&gt;&lt;br /&gt;                foreach (MyTreeNode nodeGrandChild in nodeChild.MyChildren)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;                {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//access the children of each of root's children&lt;br&gt;&lt;br /&gt;&lt;br /&gt;                }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;            Console.ReadLine();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This doesn't help you solve it using a C# struct, but it does get you out of using pointers.&lt;br&gt;Reply:I believe in C#, if you want to use pointers you will have to declare the struct as 'unsafe' as well.  Example:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;public unsafe struct mytree{ ....}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The thing about that is the fact the types, and properties declared within a piece of unsafe code will not be handled by the CLR.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://salary-survey2.blogspot.com/&gt;salary survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6989241910772038014?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6989241910772038014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/structures-and-pointers-in-c-how-can-i.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6989241910772038014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6989241910772038014'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/structures-and-pointers-in-c-how-can-i.html' title='Structures and pointers in C#. How can I implement them?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-3813479453194946906</id><published>2009-07-14T20:04:00.001-07:00</published><updated>2009-07-14T20:04:18.749-07:00</updated><title type='text'>Pointers in c++ - i want only the pointers sorted?</title><content type='html'>char *cities[ ]={"New York","Washington","Durham","Cincinati"}...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char **c;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;c = cities; // i want to have the pointers sorted but the cities must remain in exact place.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Pointers in c++ - i want only the pointers sorted?&lt;br&gt;Assuming you want them sorted into an order based on what they point to. Then create a parallel array in which they are placed in sorted order. Changing there order there doesn't change the location they point to or the ordering in the original array. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In the above assigning&lt;br&gt;&lt;br /&gt;&lt;br /&gt;c = cities&lt;br&gt;&lt;br /&gt;&lt;br /&gt;makes c and alias for cities. What you what to do is make a deep copy as below.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char* cities[] = {.....};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char** toSort = calloc(sizeof(cities)/sizeof(*cities), sizeof(char*));&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for (int i = 0; i %26lt; sizeof(cities)/sizeof(*cities); ++i)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    toSort[i] = cities[i];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//sort toSort;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cities[]  is left in it's original order&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the cities in toSort are ordered&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-3813479453194946906?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/3813479453194946906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointers-in-c-i-want-only-pointers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3813479453194946906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3813479453194946906'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointers-in-c-i-want-only-pointers.html' title='Pointers in c++ - i want only the pointers sorted?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-8391691519008656678</id><published>2009-07-14T20:04:00.000-07:00</published><updated>2009-07-14T20:04:02.587-07:00</updated><title type='text'>I need a sample exam and answers on the dynamic data structures in C++(Pointers,Linked Lists &amp;recursion)?</title><content type='html'>You have not stated how complex you want this exam to be.  I could very easily ask questions and give answers that would not be reasonable to ask at a first year bachelors level but would be at a first year graduate level.  However I will assume this is a test at a first year post secondary level.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(1) Q: Write a funtion that prints out the contents of a singly linked list in reverse. (hint use recursion)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void write_reverse(Element *first){&lt;br&gt;&lt;br /&gt;&lt;br /&gt;__if (first){&lt;br&gt;&lt;br /&gt;&lt;br /&gt;______write_reverse(first -%26gt; next );&lt;br&gt;&lt;br /&gt;&lt;br /&gt;______cout %26lt;%26lt; first -%26gt; data %26lt;%26lt; ' ';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;__}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(2) Q: Write a funtion that uses recursion to place an element at the end of a singly linked list.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void put_last_rec( Element *%26amp; first, int d){&lt;br&gt;&lt;br /&gt;&lt;br /&gt;__if (! first)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;____first = new Element(0, d);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;__else&lt;br&gt;&lt;br /&gt;&lt;br /&gt;____put_last_rec(first -%26gt; next , d );&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(3) Q: Describe what the following code is:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;class unknown {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;public&lt;br&gt;&lt;br /&gt;&lt;br /&gt;__unknown *forward, *backward;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;__int data;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;__unknown(unkown *f=0, unknown *b=0, int d=0)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;____ : forward(f), backward(b), data(d) {}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A: This is a class for a doubly linked list with values of type int.  This class contains two pointers, an integer, a constructor for constructing new lists which also acts as a default constructor.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This exam has pointers, linked lists, and recursion and should be of decent difficulty for an introduction to programming type class.  Hope this helps.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://about-me-survey.blogspot.com/&gt;survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-8391691519008656678?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/8391691519008656678/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-need-sample-exam-and-answers-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8391691519008656678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8391691519008656678'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-need-sample-exam-and-answers-on.html' title='I need a sample exam and answers on the dynamic data structures in C++(Pointers,Linked Lists &amp;amp;recursion)?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-1171153247983410548</id><published>2009-07-14T20:03:00.002-07:00</published><updated>2009-07-14T20:03:47.492-07:00</updated><title type='text'>Can I get algorithm/source code  for matrix multiplication using C pointers?</title><content type='html'>main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int B[][3]={{1, 0, -2},&lt;br&gt;&lt;br /&gt;&lt;br /&gt;           {0, 3, -1}};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int C[][2]={{0, 3},&lt;br&gt;&lt;br /&gt;&lt;br /&gt;           {-2, -1},&lt;br&gt;&lt;br /&gt;&lt;br /&gt;           {0, 4}};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int A[2][2]={{0, 0}, {0,0}};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int n1=2, n2=3, n3=2;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int i, j, k;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for( i=0; i%26lt;n1; i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    for( k=0; k%26lt;n3; k++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;      for( j=0; j%26lt;n2; j++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;        (*(*(A+i)+k)) +=  (*(*(B+i)+j)) * (*(*(C+j)+k));&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(i=0; i%26lt;n1; i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   for(j=0; j%26lt;n3; j++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;       printf("%d ", A[i][j]);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   printf("\n");&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-1171153247983410548?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/1171153247983410548/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-i-get-algorithmsource-code-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1171153247983410548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1171153247983410548'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-i-get-algorithmsource-code-for.html' title='Can I get algorithm/source code  for matrix multiplication using C pointers?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5965795103929971326</id><published>2009-07-14T20:03:00.001-07:00</published><updated>2009-07-14T20:03:31.309-07:00</updated><title type='text'>Can anyone tell me about online books on c++ pointers?</title><content type='html'>cout%26lt;%26lt;"Pointers are cool" lol&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;they r just one of the amzing feautures in C++&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;have a look @:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://cplus.about.com/od/beginnerctutor...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.programmingtutorials.com/cplu...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://digg.com/programming/C_pointers,_...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;feel free to pose any Questoin if u meed more help in C++&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;HuS&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Can anyone tell me about online books on c++ pointers?&lt;br&gt;I'm sorry. I couldnt find any.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5965795103929971326?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5965795103929971326/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-anyone-tell-me-about-online-books.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5965795103929971326'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5965795103929971326'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-anyone-tell-me-about-online-books.html' title='Can anyone tell me about online books on c++ pointers?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-1094800721239542460</id><published>2009-07-14T20:03:00.000-07:00</published><updated>2009-07-14T20:03:14.070-07:00</updated><title type='text'>Using pointers in data structures in C?</title><content type='html'>If I create a data structure (in C) with a pointer in it, then a pointer of that structure's type:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct data {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  int a;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  int *ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct data *info;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;How do I initialize that pointer? Specifically, I'm trying to use malloc to allocate storage space for the pointer to point to.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I tried all of these:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;info.*ptr = (int *)malloc(sizeof(int)*4);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*info.*ptr = (int *)malloc(sizeof(int)*4);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;info.ptr = (int *)malloc(sizeof(int)*4);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*info.ptr = (int *)malloc(sizeof(int)*4);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;But nothing seems to work. What am I doing wrong?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Using pointers in data structures in C?&lt;br&gt;Since you declared info as a pointer you first need to allocate the memory for that object with:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;info=(struct data *)malloc(sizeof(data));&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;then&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;info-%26gt;ptr=(int*)malloc(sizeof(int)*4);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This will basically create an array in ptr that can be referenced with info-%26gt;ptr[0], info-%26gt;ptr[1], etc.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Make sure you free both sets of allocated memory when you are done with it.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Note that (*info).ptr will also work to reference that item.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-1094800721239542460?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/1094800721239542460/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/using-pointers-in-data-structures-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1094800721239542460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1094800721239542460'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/using-pointers-in-data-structures-in-c.html' title='Using pointers in data structures in C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-7740622334711440770</id><published>2009-07-14T20:02:00.002-07:00</published><updated>2009-07-14T20:02:58.085-07:00</updated><title type='text'>How to work with c pointers?</title><content type='html'>A pointer refers to an address that points to another variable.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So say you have an integer x, and another integer y.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int x, y;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You might have a pointer to the "current" integer:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *current;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now you could write something like this:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;current=%26amp;x;  /* make current point to x */&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*current=5;  // set x to 5&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The advantage here is that you can later set current to %26amp;y and then code that used to modify x will now modify y.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This is useful in functions where you want to modify an argument. For example:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void square(int *x)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  *x=*x * *x;  &lt;br&gt;&lt;br /&gt;&lt;br /&gt;  }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You might call this as:&lt;br&gt;&lt;br /&gt;&lt;br /&gt; int z=50;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; square(%26amp;z);&lt;br&gt;&lt;br /&gt;&lt;br /&gt; /* now z= 50*50 */&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Of course your could write square in this case to return the result, but perhaps you are returning some result already and want to return something else. For example, suppose you want to write a function that gets two numbers and returns the largest and the smallest, you might write:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int numsort(int a, int b, int *smallest)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  if (a%26gt;b) { *smallest=b; return a; }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  else { *smallest=a; return b; }  /* if equal, doesn't matter */&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  return 0; // not reached&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Another important use is when working with arrays. An array name is a pointer to the first element of the array:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int x[50];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You can even have pointers to functions. For example, you might have a table of function pointers to execute different code based on an index.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now x is the same as %26amp;x[0] and incrementing x will point at subsequent elements.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Finally, dynamic allocation uses pointers. So another way to handle the array above would be:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *x;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;x=malloc(50*sizeof(int));  /* make array of 50 integers */&lt;br&gt;&lt;br /&gt;&lt;br /&gt;/* Now x works just like an array */&lt;br&gt;&lt;br /&gt;&lt;br /&gt;. . .&lt;br&gt;&lt;br /&gt;&lt;br /&gt;free((void *)x);&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How to work with c pointers?&lt;br&gt;You can also have pointers to functions. Take the addresses of various functions and put them in an arrays of function pointers. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;This is useful in implementing state machines and executing different functions according to rules built around calculations rather then if..then..else constructs&lt;br&gt;Reply://Declare a pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *i; // just prefix a normal variable with *&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//Once you are done with your pointer just delete it&lt;br&gt;&lt;br /&gt;&lt;br /&gt;delete i;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// to access member functions in pointers use "-%26gt;" instead of "."&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;this-%26gt;setText("hello");&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Note: This is c++, c uses the same conventions with the exception of "//" = "/* */"&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://land-survey2.blogspot.com/&gt;land survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-7740622334711440770?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/7740622334711440770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-work-with-c-pointers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7740622334711440770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7740622334711440770'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-work-with-c-pointers.html' title='How to work with c pointers?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-8580353156288931068</id><published>2009-07-14T20:02:00.001-07:00</published><updated>2009-07-14T20:02:43.574-07:00</updated><title type='text'>Help in C pointers?</title><content type='html'>#include"stdio.h"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include"conio.h"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void bubblesort(char *R[], int a); //function declaration//&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *restname[20][30]; //Variable in main//&lt;br&gt;&lt;br /&gt;&lt;br /&gt;bubblesort(restname[30], 20)//Function bubblesort in main//&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void bubblesort(char *R[], int a)//function bubble sort//&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int i, j; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *hold;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(i= 0; i %26lt; a; i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; for(j=0; j%26lt;a-1; j++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; if(R[j] %26lt; R[j+1])&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; hold = R[j];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;R[j] = R[j+1];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;R[j+1] = hold;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(i=0; i%26lt;a; i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; printf("%s", R[i]);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("\n");&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;} //end function//&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;help with the declaration part&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Help in C pointers?&lt;br&gt;I see several potential problems...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(1) The function declaration for bubblesort goes above the main, not in it. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(2) The function itself appears within the main function. C doesn't allow nested functions.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(3) That function has as its first parameter an array of pointers to char. Fine, we sort arrays of pointers all the time. But then the sort algorithm sorts by the value of the pointer itself, not the value of the char indicated by that pointer. Sorting the pointers in this manner makes little sense.&lt;br&gt;Reply:first any function declartion and definition should be out of main scope &lt;br&gt;&lt;br /&gt;&lt;br /&gt;not inside the main,the only thing inside the main is the fucntion call  :)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;secondly your array restname is empty ? why ? what are you sorting ?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;good luck :)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include"stdio.h"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include"conio.h"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void bubblesort(char *R[], int a)//function bubble sort//&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int i, j; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *hold;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;hold = new char;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(i= 0; i %26lt; a; i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(j=0; j%26lt;a-1; j++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt; {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;if(R[j] %26lt; R[j+1])&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;hold = R[j];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;R[j] = R[j+1];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;R[j+1] = hold;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  }&lt;br&gt;&lt;br /&gt;&lt;br /&gt; }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(i=0; i%26lt;a; i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt; {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%s", R[i]);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("\n");&lt;br&gt;&lt;br /&gt;&lt;br /&gt; }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;} //end function//&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *restname[20][30]; //Variable in main//&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;bubblesort(restname[30], 20);//Function bubblesort in main//&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-8580353156288931068?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/8580353156288931068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/help-in-c-pointers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8580353156288931068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8580353156288931068'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/help-in-c-pointers.html' title='Help in C pointers?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5017788076270078093</id><published>2009-07-14T20:02:00.000-07:00</published><updated>2009-07-14T20:02:26.249-07:00</updated><title type='text'>C pointers, give practical examples?</title><content type='html'>Pointer is a variable that contains the address of another variable. (or in other words the address of a memory location). in 16-bit segmented memory model, there are two types of pointers: near pointer, that points in the same memory segment, and far pointer, which can point to beyond the current memory segment. Near pointer is actually a 16-bit integer that addresses a memory location in the segment pointed to by DS register of processor. While far pointer is 32-bit integer which contains both segment and offset address.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;in 32-bit flat addressin mode, pointer is always a 32-bit integer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;One important thing to understand is pointer itself does not contain any data (or code sometimes), rather it contains the address of a memory location where data (or code) can be found.  Using this technique is called indirect addressing and multiple indirection could be possible. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I give hereunder a code example which uses the pointers. Two operators in C are very important when using pointers. * is called 'value at' and %26amp; is called 'address of'. here's the code in C:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;conio.h%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;stdio.h%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int x=100;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *ax=%26amp;x;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%d, %d", x, *ax); // will print 100, 100&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%d",ax); //will print memory address of x&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*ax=200; // you are actually changing x with its pointer ax&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%d, %d", x, *ax); // will print 200, 200&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%d",ax); //will print memory address of x&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;try this code in a 16-bit C version. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;hope that answers the question&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C pointers, give practical examples?&lt;br&gt;pointer is a variable it stores the address of another variable.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;say for example &lt;br&gt;&lt;br /&gt;&lt;br /&gt;you are declaring a variable integer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int i;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;i=10;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int occupies 2 bytes in the memory&lt;br&gt;&lt;br /&gt;&lt;br /&gt;say for example &lt;br&gt;&lt;br /&gt;&lt;br /&gt;memory  address will look like this&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;8000 8001 8002 8003 ......9000&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;when you store it in the memory it will converted to binary and occupies the 2 bytes&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;here int i will occupie from 8000 to 8016&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr=%26amp;i (address of i)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;so now ptr contains the starting address of i ...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;here i starting address is 8000. so ptr= 8000&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*ptr = value at address ( 10)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26amp;i = address of i (8000)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26amp;ptr= address of ptr ( prt is also variable so it will occupy some space in memmory it will return that base address&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for better understanding &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;buy the book named  "pointers in c " by yaswant kanithkar&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5017788076270078093?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5017788076270078093/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers-give-practical-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5017788076270078093'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5017788076270078093'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers-give-practical-examples.html' title='C pointers, give practical examples?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2980129773682623712</id><published>2009-07-12T21:11:00.000-07:00</published><updated>2009-07-12T21:11:02.987-07:00</updated><title type='text'>C++ Pointers?</title><content type='html'>Say you know a memory location address (say 0x22ff70) and you want to know what is stored there (if anything), how do you go about printing the contents on screen?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C++ Pointers?&lt;br&gt;Casting, that is the magic of C++.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Try these articles. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.boost.org/libs/conversion/cas...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://en.wikipedia.org/wiki/Pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.informit.com/guides/content.a...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Good luck&lt;br&gt;Reply:U can store this address in a pointer. Get the value thro' *&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I think its correct. I studied this long back. Sorry if am wrong&lt;br&gt;Reply:If you want to print the valud of a variable you "Printf("%i",varr). (For example)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If its a pointer you have to "Printff("%i";%26amp;point). You have to tell the printing function to print not the value of the pointer (0x22ff70 in this case) but the value of the address the pointer points :).&lt;br&gt;Reply:If you know exactly data type kept at this address, do the following:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;known_data_type * ptr = (known_data_type) void_pointer;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// print your known data here...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In another case, you cah just cast this address to char* or unsigned char * and get some dump:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;unsigned char * up = (unsigned char *) void_pointer;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;dump( up, any_size_you_need_if you_know_it);&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2980129773682623712?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2980129773682623712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers_12.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2980129773682623712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2980129773682623712'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers_12.html' title='C++ Pointers?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4582369473985253233</id><published>2009-07-12T21:10:00.002-07:00</published><updated>2009-07-12T21:10:47.951-07:00</updated><title type='text'>C++ pointers question?</title><content type='html'>I understand points and stuff but where would I use it? they seem useless and seem like something I would never use.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;can you give me some examples and maybes some codes to help me understand when I would use them?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Thanks,&lt;br&gt;&lt;br /&gt;&lt;br /&gt;S_R_S&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C++ pointers question?&lt;br&gt;Pointer code is more educational than practical. You really need to fully understand the usage of memory and pointers to store values in order to write efficient code and manage memory correctly.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;My recollection from school is that most pointer operations were performed in lists, data collections, and sorting methods. These are high level ops that will already be written into the pre-existing utility libraries that you will frequently use. But you really need to understand what is going on under the covers.&lt;br&gt;Reply:We can define a variable in C++ to store a memory address. A pointer in C++ is said to "point to" the memory address that is stored in it. Also, when defining a C++ pointer variable, we must specify the type of variable to which it is pointing. For example, to define a pointer, which will store a memory address at which exists an int, we can do the following:  &lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *p,a;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;here a is a ordinary variable,p is a pointer variable to store the address of a.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;a=5;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p=%26amp;a;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;where a contains the value 5 and p contains the address of a(memory address)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;here '%26amp;' is a 'reference' or 'address operator'&lt;br&gt;Reply:Scott, C++ is a language of pointers. It's probably difficult for you to understand this now; however, if you keep at it, you'll eventually see the power of pointers. All the crap you're learning about classes are in fact teaching you about pointers.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Example. We have a class called location. In the location class, we have GPS Latitude and GPS Longitude and other stuff.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;class location&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; DOUBLE GPSLat;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; DOUBLE GPSLong;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; DOUBLE Altitude;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; VOID  function1(....)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;From the location class, we'll derive a Ship class and Human class.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;class Ship::location&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; DOUBLE heading;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; DOUBLE speed;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; etc.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;class Human::location&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; BOOL  Man;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; DOUBLE Height;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; DOUBLE Weight;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; etc.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;From our main program we have five boats (from ship) and four Eskimos&lt;br&gt;&lt;br /&gt;&lt;br /&gt;from human.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Ship  boat[5];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Human  Eskimo[4];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;......&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// somewhere in here we want to print the location data &lt;br&gt;&lt;br /&gt;&lt;br /&gt;// of a ship or an Eskimo. It'll be user or programmatically&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// selectable &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;location* myTarget;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;myTarget = %26amp;boat[4]; or myTarget = %26amp;Eskimo[0]; or, etc. (SOME INPUT)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf( "%f, %f", myTarget-%26gt;GPSLat, myTarget-%26gt;GPSLong );&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Note how the printf function does NOT need to change. It will&lt;br&gt;&lt;br /&gt;&lt;br /&gt;work on all ships or Eskimos and it does not include even an index&lt;br&gt;&lt;br /&gt;&lt;br /&gt;into the arrays. You would obviously make a more meaningful &lt;br&gt;&lt;br /&gt;&lt;br /&gt;routine than just a printf. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps. (C++ in one minute).&lt;br&gt;Reply:Pointers are not easier to understand but they are much easier to understand if you go back to the C programming language.  C was written originally on computers so simple you can buy calculators today which are more complicated and have more memory.  For that reason, a lot of under the hood stuff was and is pretty much out in the open.  An example of this would be pointers and arrays.  Everything in C, we are told, is passed as a value except arrays.  These are passed by the address of the first element Array[0].  In practical terms, this means when you pass an array to a function what you have is a pointer to that array, on which you can (though it's not recommended) do pointer arithmatic.  You are better off creating a temporary pointer, assigning it Array[0]'s address and using that because it will help you keep track of things.  With C++ you can use the %26amp; operator to pass anything by reference, and it is certainly less cumbersome, but the reason C code is supposed to compile into such fast and efficient machine code is it stays close to what the hardware is actually doing and what you are trading off is readability for efficiency.  Read Kernighan and Ritchie's The C Programming Language even if you are not particularly interested in programming in C.  You'll find source code for many functions in cstdio and cstlib which use pointers, and frankly which if you come to understand (and these guys are good at explaining) will help you understand pointers better than anyone at Yahoo! Answers&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://2survey-software.blogspot.com/&gt;survey software&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4582369473985253233?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4582369473985253233/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers-question.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4582369473985253233'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4582369473985253233'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers-question.html' title='C++ pointers question?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2093066469434945739</id><published>2009-07-12T21:10:00.001-07:00</published><updated>2009-07-12T21:10:30.767-07:00</updated><title type='text'>Why do c pointers are faster than variables accessing?</title><content type='html'>why the accesing time is fast of pointers than that of variables&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Why do c pointers are faster than variables accessing?&lt;br&gt;When accessing a variable there may be a need to compute the address of the variable, while the pointer has that address already computed.  For example, if the variable is an element of&lt;br&gt;&lt;br /&gt;&lt;br /&gt;an array, accessed as a[b], a computation of the address using &lt;br&gt;&lt;br /&gt;&lt;br /&gt;b would be necessary, making it slower.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2093066469434945739?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2093066469434945739/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-do-c-pointers-are-faster-than.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2093066469434945739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2093066469434945739'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-do-c-pointers-are-faster-than.html' title='Why do c pointers are faster than variables accessing?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2988506701375225494</id><published>2009-07-12T21:10:00.000-07:00</published><updated>2009-07-12T21:10:15.137-07:00</updated><title type='text'>C++ Pointers; Can someone use illustrations and explain?</title><content type='html'>Can someone give a simple explanation of the use of Pointers, how they work, and their purpose. Illustrations would be a +.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C++ Pointers; Can someone use illustrations and explain?&lt;br&gt;What are pointers? &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers are aptly named: they "point" to locations in memory. Think of a row of safety deposit boxes—of various sizes—at a local bank. Each safety deposit box will have a number associated with it, so that the teller can quickly look it up. These numbers are like the memory addresses of variables. A pointer in the world of safety deposit boxes would simply be anything that stored the number of another safety deposit box. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Perhaps you have a rich uncle who stored valuables in his safety deposit box, but decided to put the real location in another, smaller, safety deposit box that only stored a card with the number of the large box with the real jewelery. The safety deposit box with the card would be storing the location of another box; it would be equivalent to a pointer. In the computer, pointers are just variables that store memory addresses, usually the addresses of other variables. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The cool thing is that once you can talk about the address of a variable, you'll then be able to go to that address and retrieve the data stored in it. If you happen to have a huge piece of data that you want to pass into a function, it's a lot easier to pass its location to the function than to copy every element of the data! Moreover, if you need more memory for your program, you can request more memory from the system—how do you get "back" that memory? The system tells you where it is located in memory. In other words, you get a memory address back. And you need pointers to store the memory address. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A note about terms: the word pointer can refer either to a memory address itself, or to a variable that stores a memory address. Usually, the distinction isn't really that important: if you pass a pointer variable into a function, you're passing the value stored in the pointer—the memory address. When some people want to talk about a memory address, they refer to it as a memory address. When they want a variable that stores a memory address, they call it a pointer. When a variable stores the address of another variable, they say that it is "pointing to" that variable. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;___________&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointer Syntax&lt;br&gt;&lt;br /&gt;&lt;br /&gt;___________&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers require a bit of new syntax because when you have a pointer, you need the ability to request both the memory location it stores and the value stored at that memory location. Moreover, since pointers are somewhat special, you need to tell the compiler when you declare your pointer variable that the variable is a pointer, and tell the compiler what type of memory it points to. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The pointer declaration looks like this: &lt;br&gt;&lt;br /&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26lt;variable_type%26gt; *%26lt;name%26gt;; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For example, you could declare a pointer that stores the address of an integer with the following syntax: &lt;br&gt;&lt;br /&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *pointer1;   // points to an integer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Notice the use of the *. This is the key to declaring a pointer; if you add it directly before the variable name, it will declare the variable to be a pointer. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Important: if you declare multiple pointers on the same line, you must precede each of them with an asterisk: &lt;br&gt;&lt;br /&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;// one pointer, one regular int&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *pointer1, non_pointer1;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// two pointers&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *pointer1, *pointer2;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;As I mentioned, there are two ways to use the pointer to access information: it is possible to have it give the actual address to another variable. To do so, simply use the name of the pointer without the *. However, to access the actual memory location, use the *. The technical name for this doing this is 'dereferencing the pointer.' Basically, you're taking the reference to some memory address and following it, to retrieve the actual value. It can be tricky to keep track of when you should add the asterisk. Remember that the pointer's natural use is to store a memory address; so when you use the pointer, i.e., pointer1, then, it evaluates to the address. You have to add something extra—the asterisk (*pointer1)—in order to retrieve the value stored at the address. You'll probably do that an awful lot. Nevertheless, the pointer itself is supposed to store an address, so when you use the bare pointer, you get that address back. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointing to Something: Retrieving an Address&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In order to have a pointer actually point to another variable it is necessary to have the memory address of that variable also. To get the memory address of a variable (its location in memory), put the %26amp; sign in front of the variable name. This makes it give its address. This is called the address-of operator, because it returns the memory address. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Conveniently, both ampersand and address-of start with 'a;' that's a useful way to remember that you use %26amp; to get the address of a variable. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For example: &lt;br&gt;&lt;br /&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;iostream%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{ &lt;br&gt;&lt;br /&gt;&lt;br /&gt;  int x;            // A normal integer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  int *p;           // A pointer to an integer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  p = %26amp;x;           // Read it, "assign the address of x to p"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  cin%26gt;%26gt; x;          // Put a value in x, we could also use *p here&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  cin.ignore();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  cout%26lt;%26lt; *p %26lt;%26lt;"\n"; // Note the use of the * to get the value&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  cin.get();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The cout outputs the value stored in x. Why is that? Well, let's look at the code. The integer is called x. A pointer to an integer is then defined as p. Then it stores the memory location of x in pointer by using the address-of operator (%26amp;) to get the address of the variable. Using the ampersand is a bit like looking at the label on the safety deposit box to see its number rather than looking inside the box, to get what it stores. The user then inputs a number that is stored in the variable x; remember, this is the same location that is pointed to by p. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The next line then passes *p into cout. *p performs the "dereferencing" operation on p; it looks at the address stored in p, and goes to that address and returns the value. This is similar to looking inside a safety deposit box only to find the number of (and, presumably, the key to ) another box, which you then open. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Notice that in the above example, pointer is initialized to point to a specific memory address—before it is used. If this was not the case, it could be pointing to anything. This can lead to extremely unpleasant consequences to the program. For instance, the operating system will probably prevent you from accessing memory that it knows your program doesn't own: or else, your program would crash. If it let you use unowned memory, you could mess with the memory of any running program. For example, if you had a document opened in Word, you could change the text! Fortunately, Windows and other modern operating systems will stop you from accessing that memory—by causing your program to crash. To avoid crashing your program, you should always initialize pointers before you use them. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;[Side note: It is also possible to initialize pointers using free memory. This allows dynamic allocation of array memory. It is most useful for setting up structures called linked lists.] &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The keyword 'new' is used to initialize pointers with memory from free store (a section of memory available to all programs). The syntax looks like the example: &lt;br&gt;&lt;br /&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *ptr = new int;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;It initializes ptr to point to a memory address of size int (because variables have different sizes, number of bytes, this is necessary). The memory that is pointed to becomes unavailable to other programs. This means that the careful coder should free this memory at the end of its usage. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The delete operator frees up the memory allocated through new. To do so, the syntax is as in the example: &lt;br&gt;&lt;br /&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;delete ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;After deleting a pointer, it is a good idea to reset it to point to 0. When 0 is assigned to a pointer, the pointer becomes a null pointer, in other words, it points to nothing. By doing this, when you do something foolish with the pointer, you find out immediately—instead of later, when you have done considerable damage. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In fact, the concept of the null pointer is frequently used as a way of indicating a problem—for instance, some functions left over from C return 0 if they cannot correctly allocate memory (notably, the malloc function).&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2988506701375225494?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2988506701375225494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers-can-someone-use.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2988506701375225494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2988506701375225494'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers-can-someone-use.html' title='C++ Pointers; Can someone use illustrations and explain?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-7021560946908431108</id><published>2009-07-12T21:09:00.003-07:00</published><updated>2009-07-12T21:09:59.605-07:00</updated><title type='text'>A program in C++ pointers.?</title><content type='html'>please help me write a program to search for a given character and print the streing from the point of match using pointers.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;i know to do it without pointers but i am asked by my sir to do it using pointers. please help me. you wouldn't be doing my home work but really helping me......&lt;br&gt;&lt;br /&gt;&lt;br /&gt;please help&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;A program in C++ pointers.?&lt;br&gt;First things first, 'char * s' is the same as the character array 'char s[].'  In this example, s is what is commonly called a c-style string, which is a null-terminated array of characters.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For example, if you use the string 'cat', the c-string would be the character array {'c','a','t',0 (the number zero, not the character zero)}.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Just to note, c-strings can be initialized easily like this: &lt;br&gt;&lt;br /&gt;&lt;br /&gt;char s[] = "cat";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;As I said before, char * s is the same as char s[] and they are interchangeable.  In both cases, s points to the address of the first element of the array.  When you say s[index], you are getting the value of the object at memory location s + index.  You can do the same thing with pointers by first adding index to s and then dereferencing s, like so: *(s+index).   This is what is going on in this example.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Lets say we're using the string 'cat' and the character we're looking for is 'a'.  So this algorithm starts off with 'cat' being stored in a null-terminated character array s.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26gt;while((c!=*s) %26amp;%26amp; (*s)){&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This will loop as long as the character at s in not equal to character c and while the character at s in not equal to zero.  For our first iteration, s is still pointing to the first character of the string and by dereferencing s (via *s) we get the character 'c'.  Since this is neither equal to the character stored in c, 'a', nor is it equal to zero, we will continue.  &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;When the end of the string is reached and s points to the null-terminating character, zero, the while loop will end because in C a value of zero is the same as false.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26gt;s++; }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This increments the pointer, essentially behaving as an iterator.  When you increment a pointer, it then points to the next character in the array, which in our case would be 'a'.  Also note that the string represented by c-strings go from the character the pointer points to the null-character, so doing this effectively removes the first character and makes the string 'at'.    &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;After s is incremented, the next iteration will exit the while loop because now *s = 'a'&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26gt;return s;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;this obviously returns s, which now points to the c-string 'at'.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;To hide the confusing parts of pointers, you could also do it like this:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int index = 0;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;while( s[index] != c %26amp;%26amp; s[index] ) {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;index++;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return s;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This method still uses pointers, except they are referenced in a more easily understood way.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers are a very important topic.  They may seem difficult or confusing at first, but once you get the hang of them they can be a very powerful and useful tool that will make your life much much easier.&lt;br&gt;Reply:const char * strchr(const char *s, char c)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; char c2;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt;&lt;br /&gt; for (const char *p = s; (c2 = *p) != 0; ++p)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  if (c2 == c) return p;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt;&lt;br /&gt; return null;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-7021560946908431108?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/7021560946908431108/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/program-in-c-pointers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7021560946908431108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7021560946908431108'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/program-in-c-pointers.html' title='A program in C++ pointers.?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5909966131419279387</id><published>2009-07-12T21:09:00.002-07:00</published><updated>2009-07-12T21:09:41.586-07:00</updated><title type='text'>I need help with pointers in C++?</title><content type='html'>Write a function that takes a C string as an input parameter and reverses the string. The function&lt;br&gt;&lt;br /&gt;&lt;br /&gt;should use two pointers, 'front' and 'rear'. The 'front' pointer should initially reference the first &lt;br&gt;&lt;br /&gt;&lt;br /&gt;character in the string, and the 'rear' pointer should initially reference the last character in the &lt;br&gt;&lt;br /&gt;&lt;br /&gt;string. Reverse the string by swapping the characters referenced by 'front' and 'rear', then increment &lt;br&gt;&lt;br /&gt;&lt;br /&gt;front to point to the preceding character, and so on, until the entire string is reversed. Write a &lt;br&gt;&lt;br /&gt;&lt;br /&gt;main program to test your function on various strings of both even and odd length.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;iostream%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;string%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void swap_char(int* pFront, int* pRear);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int main(){&lt;br&gt;&lt;br /&gt;&lt;br /&gt;string sentence;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *pFront, *pRear;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout %26lt;%26lt; "Type in a sentence of less than 40 characers: \n";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cin %26gt;%26gt; sentence;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;swap_char(pFront, pRear);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return 0;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void swap_char(int* pFront, int* pRear){&lt;br&gt;&lt;br /&gt;&lt;br /&gt;while(pRear %26gt; pFront)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; string sentence;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; char temp;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26amp;temp =&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;I need help with pointers in C++?&lt;br&gt;Some tips:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pFront and pRear should be char*, not int*.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You need to set pFront and pRear to something before calling swap_char. However, the problem statement says swap_char's argument should be a "C string". I assume it wants you to use character array, and not a C++ string object. Inconvenient as that may be, you need this signature: &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void swap_char(char * const s);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(i.e., const pointer, non-const data)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You  might think you should have this call in main() : &lt;br&gt;&lt;br /&gt;&lt;br /&gt;swap_char(sentence.c_str());&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;That won't work, though, because c_str() returns a const char*, and swap_char needs to modify the character array. You need to declare a character array, then copy the c_str from sentence. Also, there's no need to limit the input to 40 characters, or any length.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So you need something like this:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;getline(cin,sentence);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *line = new char[sentence.length()+1];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;memcpy(line,sentence.c_str(),sentence....&lt;br&gt;&lt;br /&gt;&lt;br /&gt;swap_char(line);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Why getline instead of cin's operator%26gt;%26gt;,  you ask? Try them both, you'll see. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Also, #include %26lt;cstring%26gt; for memcpy. And when you're done, don't forget to: delete [ ] line;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I'll leave the guts of swap_char for you to work out, but this should get you going in the right direction.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://survey-research2.blogspot.com/&gt;survey research&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5909966131419279387?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5909966131419279387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-need-help-with-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5909966131419279387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5909966131419279387'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-need-help-with-pointers-in-c.html' title='I need help with pointers in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-3178068150085074635</id><published>2009-07-12T21:09:00.001-07:00</published><updated>2009-07-12T21:09:26.079-07:00</updated><title type='text'>About pointers in C?</title><content type='html'>hi..uhmm..about pointers in C.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *s;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;s="hello";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;when u print the *s, the output is garbage or nonesense..&lt;br&gt;&lt;br /&gt;&lt;br /&gt;but if u print the value of s alone...hello would appear..why is this so? correct me if im wrong...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the s pointer points to the address of "hello" and when i dereference 8 it should work..by now...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;About pointers in C?&lt;br&gt;I think you're doing it wrong. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You would need something like this:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;iostream%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *s;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char mystring[] = "hello";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;s = mystring;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout %26lt;%26lt; s;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;system("Pause");&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;EDIT - I just tried this and it works, have a good day.&lt;br&gt;Reply:it won't print garbage .&lt;br&gt;&lt;br /&gt;&lt;br /&gt;it will just print h;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the pointer s will be just pointing to the first element .&lt;br&gt;&lt;br /&gt;&lt;br /&gt;so when you do a *s it will print h&lt;br&gt;Reply:its like this:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;s stored the address location&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*s stores the value stored in the first position of s&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for printf and all functions that use string (i.e. char *) values, you pass the address and all manipulation etc happens to the value stored at address using address pointer -%26gt; pointer manipulation&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;when u print as:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%s", *s); --%26gt; this should print junk&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;but when u print as:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%c", *s); --%26gt; this should print the char at first byte location of s&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;and if u print as:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%s", s); --%26gt; this should print the entire string stored in s&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;read a book on pointers, it will take too long to explain here. and its already explained very well in many books.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;also there is a chance your current program (as it is) may core dump. this is because u r defining in one statement and then assigning in another. but since you did not allocate memory before proceeding to assign, your program will core dump. to resolve this, use:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *s="hello";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;doing this does definition, allocation of memory and assignation all at the same time.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-3178068150085074635?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/3178068150085074635/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/about-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3178068150085074635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3178068150085074635'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/about-pointers-in-c.html' title='About pointers in C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-7368861361585100855</id><published>2009-07-12T21:09:00.000-07:00</published><updated>2009-07-12T21:09:09.390-07:00</updated><title type='text'>Streams and pointers in C?</title><content type='html'>Are streams in C interchangable with pointers? &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For example, can you use a stream to convert data of a string using a pointer address as the location?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;How do streams work differently then pointers?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Streams and pointers in C?&lt;br&gt;stream : continous flow of data &lt;br&gt;&lt;br /&gt;&lt;br /&gt;pointer : address pointing to memory where data persent&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-7368861361585100855?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/7368861361585100855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/streams-and-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7368861361585100855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7368861361585100855'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/streams-and-pointers-in-c.html' title='Streams and pointers in C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-7503625544986051004</id><published>2009-07-12T21:08:00.003-07:00</published><updated>2009-07-12T21:08:54.804-07:00</updated><title type='text'>Pointers in C++?</title><content type='html'>I'm learning about pointers in C++. I understand that to assign the address of var1 to the pointer var2, you &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int var1;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *var2;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;var2 = %26amp;var1;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I saw the code below just now and I don't understand it.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    int *i, j[10]; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;    double *f, g[10]; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;    int x; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    i = j; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;    f = g; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    for(x=0; x%26lt;10; x++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;      cout %26lt;%26lt; i+x %26lt;%26lt; ' ' %26lt;%26lt; f+x %26lt;%26lt; '\n';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;j[10] and g[10] are arrays so what happens if you &lt;br&gt;&lt;br /&gt;&lt;br /&gt;i = j;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;f = g;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;when I compile the code, it seems that the address of j is assigned to i and g to f. So why is there no %26amp;?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Pointers in C++?&lt;br&gt;i=j;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Is the same as&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;i = %26amp;j[0];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;And believe it or not,&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;i = j + 5;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;is the same as&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;i = %26amp;j[5];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;That is why &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout %26lt;%26lt; i+x&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Prints out the successive elements of the array.&lt;br&gt;Reply:*j or J[10] Basically in this 2 Variables your declaring that they're arrays&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*j ---- doesn't have any specified size of array&lt;br&gt;&lt;br /&gt;&lt;br /&gt;J[10] ---- the size of array is 10&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-7503625544986051004?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/7503625544986051004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7503625544986051004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7503625544986051004'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointers-in-c.html' title='Pointers in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6647396701082126785</id><published>2009-07-12T21:08:00.002-07:00</published><updated>2009-07-12T21:08:38.516-07:00</updated><title type='text'>" POINTERS"in C?</title><content type='html'>Hi! frnds,&lt;br&gt;&lt;br /&gt;&lt;br /&gt;                can anyone plz. sugest some sites on which i can get to solve some example programs in "POINTERS" in C , and also how to draw the flowchart and algorithm of a pointer program.please help....!!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;thank u!&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;" POINTERS"in C?&lt;br&gt;See there are no specific sites for this but try some good books ,online www.cplusplus.com .&lt;br&gt;Reply:My name deepak I am doing Bca and site by site i have teach C language to Bca and Btech  student.I have to tell &lt;br&gt;&lt;br /&gt;&lt;br /&gt;U because i don't thing that U have go for web site for &lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointer problem.It better to built up Ur confidence because&lt;br&gt;&lt;br /&gt;&lt;br /&gt;according  to me if anybody want  to learn C language(pointer).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;First step is that U have more than Two Books at a &lt;br&gt;&lt;br /&gt;&lt;br /&gt;time.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Second step never read the theory directly move to program Because u r waisting Ur time in reading theory.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Third daily do only two to three question because if U completed whole exercise in one day u are totally confuse.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Forth Al way do first dry run mean try do solve the question in the copy first.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;fifth than  make the program.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Sixth always solve the error using top down approach.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;seven finally U know the pointers.&lt;br&gt;Reply:There are no algorithms of "pointer programs" that I know of.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A pointer is basically a description of an address.  For instance, and this is a bit contrived, but if you gave someone your house, they would have your house.  But if you gave them the ADDRESS of your house, then they could still get the house if they want, but they wouldn't have to carry around the whole house.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Basically pointers are addresses of places in memory, so if you want to pass along a chunk of memory representing the text of a book, you can either pass along the whole text - which might be huge, and time-consuming to pass - or you could just pass the ADDRESS of the text.  If the recipient needs to get at the text, it's a small leap once you have the address, and it saves passing all that information around, which chews up resources.&lt;br&gt;Reply:Hi, &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I found the following sites with a very good examples of Pointers using C and C++&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://cis.stvincent.edu/html/tutorials/...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.cs.cf.ac.uk/Dave/C/node10.htm...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.augustcouncil.com/~tgibson/tu...&lt;br&gt;Reply:Hi,&lt;br&gt;&lt;br /&gt;&lt;br /&gt;if u use an under-dos C, maybe code below will explain lot of things to u:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;stdIO.h%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;conStrea.h%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#pragma hdrstop&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int add1(int* a, int* b)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; return *a + *b;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int add2(int%26amp; a, int%26amp; b)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; return a + b;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;constream c;    &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; int a, b;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; a = 1;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; b = 6;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; c.clrscr();&lt;br&gt;&lt;br /&gt;&lt;br /&gt; c %26lt;%26lt; add1(%26amp;a, %26amp;b) %26lt;%26lt; endl;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; c %26lt;%26lt; add2(a, b);&lt;br&gt;&lt;br /&gt;&lt;br /&gt; getch();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;HTH,&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;niccie_11&lt;br&gt;Reply:Pointers are actually poniting where you r going to save u'r information in c language, thus they cannot be shown on the flowchart or define using algorithm&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;i used www.borland.com, micrsoft sites to understand how i can use the pointers, the r deficult but if u try hard u well be able to understand them easily,&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://2survey-for-money.blogspot.com/&gt;survey for money&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6647396701082126785?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6647396701082126785/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointersin-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6647396701082126785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6647396701082126785'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/pointersin-c.html' title='&quot; POINTERS&quot;in C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2483351460838048338</id><published>2009-07-12T21:08:00.001-07:00</published><updated>2009-07-12T21:08:23.287-07:00</updated><title type='text'>String constant and pointers in C++?</title><content type='html'>Please look at the code below.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *ptr; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr = "Pointers add power to C++.\n";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout %26lt;%26lt; ptr; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Why does it print out "Pointers add power to C++"? &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;My book tells me that that "Pointers add power to C++" yields a pointer to its entry in the string table. So why doesn't the pointer print out the address of the string constant rather than the content itself? &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So if the string constant is stored in the address 0x22ff50 shouldn't the program print out 0x22ff50?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;String constant and pointers in C++?&lt;br&gt;If the string constant is stored at 0x22ff50, then what is actually stored in ptr is 0x22ff50. Fortunately for your sanity (and mine) cout is smart enough to know that when you do cout %26lt;%26lt; ptr you want to print the string at the address stored in ptr. Like the above answer says, if you want the address to print, you must cast it as a pointer to void  - cout %26lt;%26lt; (void *)ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This works through operator overloading. This answer is already too long, and explaining overloading would make it WAY too long. You will learn about it later, when you learn about classes. Basically, when you do cout %26lt;%26lt; myVar; what happens depends on what type myVar is.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Also, there is one more piece of magic that makes this work. The statement:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr = "Pointers add power to C++.\n";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;is technically invalid. As you know, pointers store addresses, not strings! A compiler extension allows this statement to work. When you assign a string constant to a pointer to char, the compiler will allocate memory to store the string, put the string in that memory, and store the address of the first character in your pointer. Here is what happens behind the scenes: (not what actually happens, but a way to visualize it)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//allocate memory to hold the string (28 chars)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//notice we need one extra char - the null character '\0' will be put at the end of the string.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *aString = new char[28];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//store the string in memory&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//You'll learn about pointer math shortly if you haven't already  &lt;br&gt;&lt;br /&gt;&lt;br /&gt;*aString = 'P';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(aString + 1) = 'o';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(aString +2) = 'i';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(aString + 3) = 'n';.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(aString + 22) = 'C';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(aString + 23) = "+";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(aString + 24) = '+';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(aString + 25) = '.';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(aString + 26) = '\n';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//append the null character&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(aString + 27) = '\0';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr = aString;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout %26lt;%26lt; ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//at the very end of your code:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;delete[] aString;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//end of diatribe, hope this helps...&lt;br&gt;Reply:This may vary by compiler, but at least with gcc, when you have&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *j = "hello";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the compiler returns an address to the static memory location of the string constant, not to a dynamically allocated array.  The conversion from the string constant acts more like a  "const char *".                          &lt;span&gt;Report It&lt;/span&gt;&lt;br /&gt;                      &lt;br&gt;Reply:all other pointers except for character pointers shows address .&lt;br&gt;&lt;br /&gt;&lt;br /&gt;but character pointer acts as simple character array in c/c++&lt;br&gt;Reply:Pointers are typed -- meaning it is a char * pointer, not a "generic" pointer like a "void *" pointer.  Thus, the compiler is aware you want a character pointer, and prints the string.  If you were to cast this to a (void*) pointer it would not do the same thing -- even though you are pointing at the same memory location.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2483351460838048338?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2483351460838048338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/string-constant-and-pointers-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2483351460838048338'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2483351460838048338'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/string-constant-and-pointers-in-c.html' title='String constant and pointers in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-1395746420886761160</id><published>2009-07-12T21:08:00.000-07:00</published><updated>2009-07-12T21:08:06.721-07:00</updated><title type='text'>Polymorphism query:In C++ can a method of a derived class be called using the pointer of the base class?</title><content type='html'>The method is not declared in the base class..&lt;br&gt;&lt;br /&gt;&lt;br /&gt;It is only defined in the derived class&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Polymorphism query:In C++ can a method of a derived class be called using the pointer of the base class?&lt;br&gt;Only if you cast the pointer to be a pointer to the derived class.  You can use the dynamic_cast operator to do this.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;DerivedClass *pDerived = dynamic_cast%26lt;DerivedClass %26gt;(pBase);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pDerived-%26gt;FcnInDerivedClass();&lt;br&gt;Reply:no you can't.becouase:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;class a&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;class b:public class a&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int b;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int getdata()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return b;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;a *pa=new a;// it is 0 byte.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;b *pb=*(%26amp;pa);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cout%26lt;%26lt;pb-%26gt;getdata(); // getdata try to access unhandled memory &lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-1395746420886761160?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/1395746420886761160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/polymorphism-queryin-c-can-method-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1395746420886761160'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1395746420886761160'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/polymorphism-queryin-c-can-method-of.html' title='Polymorphism query:In C++ can a method of a derived class be called using the pointer of the base class?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-7237928198025156761</id><published>2009-07-12T21:07:00.003-07:00</published><updated>2009-07-12T21:07:53.695-07:00</updated><title type='text'>Why does C++ have a string class when there is already char * (a pointer to type character)?</title><content type='html'>A string is much more easier to work with than the char * due to the following reasons:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;1. You have strict bounds checking in strings; char * doesn't have that. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;2. If you need to equate two strings, you can just use the = symbol, not have to call the strcpy function everytime.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;3. you can check for equality in an if condition ie u can use == to check if two strings are equal.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;4. You can access individual characters by using the .at().&lt;br&gt;&lt;br /&gt;&lt;br /&gt;5. You needn't call strlen to check the length. all that need to be called is stringvariable.size().&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;There are a lot other advantages of using string class too. Ultimately, the string class scores on the ease of use. The char * scores on the raw power that it provides. You can use either depending upon your requirement and the time you are ready to devote to coding.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Why does C++ have a string class when there is already char * (a pointer to type character)?&lt;br&gt;Char is a single entity.......'a' , '1' etc.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;But if u have a collection of characters together....."Bombay","computers"......&lt;br&gt;&lt;br /&gt;&lt;br /&gt;That is a string.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the space occupied is more 4 strings whereas character utilises only one byte.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Also way of use 4 chars and strs are different.String handling has a very huge application.However ,it should  be noted that a string is an array of characters.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;And use is so extensive that use of pointers can be sometimes tedious for the use of strings and is not always convenient and so we deal with string class independently though pointer can be used too.&lt;br&gt;Reply:char* strings are known as C strings. The usage of C strings is considerably more complex, not least because you have to be aware of memory issues.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;With C++ strings for example, you can concatenate strings or place new strings in a string variable with little thought for the underlying memory handling. With char* strings, you better be aware of issues such as null-character termination, having enough buffer space when concatenating, and so on.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In short, C++ strings is a level or two above C strings in abstraction.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-7237928198025156761?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/7237928198025156761/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-does-c-have-string-class-when-there_12.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7237928198025156761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7237928198025156761'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-does-c-have-string-class-when-there_12.html' title='Why does C++ have a string class when there is already char * (a pointer to type character)?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-281115258708750197</id><published>2009-07-12T21:07:00.002-07:00</published><updated>2009-07-12T21:07:34.657-07:00</updated><title type='text'>In C++, what is the meaning of char *  ?    How to recall this pointer ?     Any simple example..?</title><content type='html'>i'm still learning myself but try this&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.cplusplus.com/doc/tutorial/po...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;In C++, what is the meaning of char *  ?    How to recall this pointer ?     Any simple example..?&lt;br&gt;In computer memory, each byte has an address and a value.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Given the line&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char myVar = 'D';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The compiler puts the value 'D' in some memory address.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In C/C++ you can actually get that address with the %26amp; operator.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char * myValAddress = %26amp;myVal.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Think of the %26amp; operator as the "the address at" operator.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;when you see&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char * myValAddress = %26amp;myVal&lt;br&gt;&lt;br /&gt;&lt;br /&gt;read it in your head as&lt;br&gt;&lt;br /&gt;&lt;br /&gt;myValAddress equals "the address at" which myVal is stored.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now myValAddress is a "pointer" to the location where myVal is stored.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You can now either change or get the value with the variable name myVal, or change the value by "dereferencing" the address pointer with the * operator.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char newVal = myVal;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char newVal = *myValAddress;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;think of the * operator as "the value pointed to by"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;when you see&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*myValAddress = 'F';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;read it in your head as&lt;br&gt;&lt;br /&gt;&lt;br /&gt;"the value pointed to by" myValAddress equals 'F';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Any quest, email me at redflats@yahoo.com&lt;br&gt;Reply:A string.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://survey-questions.blogspot.com/&gt;survey questions&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-281115258708750197?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/281115258708750197/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/in-c-what-is-meaning-of-char-how-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/281115258708750197'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/281115258708750197'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/in-c-what-is-meaning-of-char-how-to.html' title='In C++, what is the meaning of char *  ?    How to recall this pointer ?     Any simple example..?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-1057652213887968919</id><published>2009-07-12T21:07:00.001-07:00</published><updated>2009-07-12T21:07:19.095-07:00</updated><title type='text'>In c++, what is the difference between a character array (or a pointer to one) and a literal string?</title><content type='html'>In c and in c++ a character array is an array of bytes, normally containing ASCII values.  A literal string is an sequence of ASCII characters terminated with a null ('\0').  Example:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char array[9] = { 'a','b','c','d','e','f','g','h','i','j' };&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char str[] = "abcdefghij";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *ptr = "abcdefghij";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;array[] will contain the ASCII string 'abcdefghij' without a null string terminator: example array[] contains:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]&lt;br&gt;&lt;br /&gt;&lt;br /&gt; a   b   c   d   e    f   g    h   i    j&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;str[] contains: &lt;br&gt;&lt;br /&gt;&lt;br /&gt;[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]&lt;br&gt;&lt;br /&gt;&lt;br /&gt; a   b   c   d   e    f   g    h   i    j     '\0'&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr will contain the address of the first byte of the literal string "abcdefghij"; ptr+10 will be the address of the null terminator.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;In c++, what is the difference between a character array (or a pointer to one) and a literal string?&lt;br&gt;there is some difference in memory assignment and accesing if you put alignment larger than 1. Say compiler option alignment is 8, then compile will assign 8 byte space for one char. For string, it assignes memory space for each char either one byte (ANSI) or two bytes (unicode).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Therefore, accessing those char in array will be more complicated&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-1057652213887968919?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/1057652213887968919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/in-c-what-is-difference-between.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1057652213887968919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1057652213887968919'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/in-c-what-is-difference-between.html' title='In c++, what is the difference between a character array (or a pointer to one) and a literal string?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5934740685002816377</id><published>2009-07-12T21:07:00.000-07:00</published><updated>2009-07-12T21:07:04.845-07:00</updated><title type='text'>Why does my Turbo C compiler produce a fatal error whenever I use a  pointer?</title><content type='html'>Need help.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Why does my Turbo C compiler produce a fatal error whenever I use a  pointer?&lt;br&gt;change the memory module to huge while compile ur code. try simple codes like&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *p;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p = (int *) malloc (sizeof(int));&lt;br&gt;&lt;br /&gt;&lt;br /&gt;scanf("%d", %26amp;p);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%d",*p);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;u can find differ, i think...&lt;br&gt;Reply:U might be using the pointer wrongly.... post a sample code here..&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5934740685002816377?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5934740685002816377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-does-my-turbo-c-compiler-produce.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5934740685002816377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5934740685002816377'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-does-my-turbo-c-compiler-produce.html' title='Why does my Turbo C compiler produce a fatal error whenever I use a  pointer?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-8544761503882191402</id><published>2009-07-12T21:06:00.002-07:00</published><updated>2009-07-12T21:06:49.218-07:00</updated><title type='text'>As it is a good practice that C# brought back the concept of GOTO statement and Pointer? If your answer is?</title><content type='html'>It may be down to taste but I think GOTO's should be left back in BASIC where they belong. :) Pointers are the bread and butter of c++ programming and a completely different animal.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;C# is managed code and therefore any use of pointers is restricted to areas of code marked UNSAFE. Although not bad practice all use of unsafe code should be done with caution.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;As it is a good practice that C# brought back the concept of GOTO statement and Pointer? If your answer is?&lt;br&gt;They are totally different. Pointers stores and adress of any data. Goto is related with process order of your code. In C# you dont need GOTO but  if u want to make a loop or change the direction of the code  u can use "break;"  "continue;" or call functions.&lt;br&gt;Reply:Huh?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers and GOTO statements are totally separate concepts. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;GOTO statements usually result in lazy programming. In good OO design, there's no need for &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In my opinion.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-8544761503882191402?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/8544761503882191402/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/as-it-is-good-practice-that-c-brought.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8544761503882191402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8544761503882191402'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/as-it-is-good-practice-that-c-brought.html' title='As it is a good practice that C# brought back the concept of GOTO statement and Pointer? If your answer is?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-735348766315039624</id><published>2009-07-12T21:06:00.001-07:00</published><updated>2009-07-12T21:06:32.479-07:00</updated><title type='text'>Binary tree programming in C++?</title><content type='html'>How can i make a binary tree (eg BST) using C++ pointer/reference method?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;can you please give me some code.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I know that each node will have one box to store the item and two boxes to store the pointers to each of its siblings.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;but i dont know how to code it... please help me.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Binary tree programming in C++?&lt;br&gt;This could be an example:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;class node&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    private:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    node *m_left;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    node *m_rigth;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    //a property that holds some value i.e. int value;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    public:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    //contructor&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   //destructor &lt;br&gt;&lt;br /&gt;&lt;br /&gt;   *node get_left();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   *node get_rigth();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   void set_left(node * left_node);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   void set_rigth(node * ritgth node); &lt;br&gt;&lt;br /&gt;&lt;br /&gt;   int get_value();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   void set_value(int value);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The members rigth and left node are of the same class node&lt;br&gt;Reply:There are plenty of educational institution that publish relevant materials in the internet, simply yahoo or google them.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Among what I found are:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://cis.stvincent.edu/html/tutorials/...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://math.hws.edu/eck/cs225/s03/binary...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://cslibrary.stanford.edu/110/Binary...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;HTH!&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://surveys4.blogspot.com/&gt;surveys&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-735348766315039624?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/735348766315039624/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/binary-tree-programming-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/735348766315039624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/735348766315039624'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/binary-tree-programming-in-c.html' title='Binary tree programming in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6094360958352932032</id><published>2009-07-12T21:06:00.000-07:00</published><updated>2009-07-12T21:06:17.325-07:00</updated><title type='text'>C++ Pointers to Strings?</title><content type='html'>I'm writing a C++ program in 3 separate files. Here's some of the pseudocode:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Rectangle.h&lt;br&gt;&lt;br /&gt;&lt;br /&gt;_________&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;private *char name;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;rectangle&lt;br&gt;&lt;br /&gt;&lt;br /&gt;deconstructor &lt;br&gt;&lt;br /&gt;&lt;br /&gt;getName&lt;br&gt;&lt;br /&gt;&lt;br /&gt;setName&lt;br&gt;&lt;br /&gt;&lt;br /&gt;draw&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Rectangle.cpp&lt;br&gt;&lt;br /&gt;&lt;br /&gt;_________&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;default constructor: name = "bleh";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;constructor: [asks the user to enter a name and prints it back]&lt;br&gt;&lt;br /&gt;&lt;br /&gt;draw: [print name]&lt;br&gt;&lt;br /&gt;&lt;br /&gt;getName: gets the name&lt;br&gt;&lt;br /&gt;&lt;br /&gt;setName: modifies the name&lt;br&gt;&lt;br /&gt;&lt;br /&gt;deconstructor: deletes the string&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;TestRectangle.cpp &lt;br&gt;&lt;br /&gt;&lt;br /&gt;___________&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Rectangle r1;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;r1.draw();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;r1.getName();&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;How do I... er... do all of this? I have to allocate memory for the string using the new keyword.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I've been trying to look this stuff up but can't seem to find anything helpful.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C++ Pointers to Strings?&lt;br&gt;"Algorithms + Data Structures = Programs", by Wirth.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You evidently learned C++ before you learned programming.  Take a break and learn programming now.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6094360958352932032?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6094360958352932032/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers-to-strings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6094360958352932032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6094360958352932032'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers-to-strings.html' title='C++ Pointers to Strings?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-7840111020444211995</id><published>2009-07-12T21:05:00.003-07:00</published><updated>2009-07-12T21:05:58.621-07:00</updated><title type='text'>If you are using C language to implement the heterogeneous linked list, what pointer type will you use?</title><content type='html'>The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;If you are using C language to implement the heterogeneous linked list, what pointer type will you use?&lt;br&gt;no doubt you must use void pointer because it can be used to reference all data tyes.....&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-7840111020444211995?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/7840111020444211995/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/if-you-are-using-c-language-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7840111020444211995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7840111020444211995'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/if-you-are-using-c-language-to.html' title='If you are using C language to implement the heterogeneous linked list, what pointer type will you use?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4888192256869178515</id><published>2009-07-12T21:05:00.002-07:00</published><updated>2009-07-12T21:05:43.041-07:00</updated><title type='text'>C++ pointers and 2D arrays?</title><content type='html'>please read the code and help me out&lt;br&gt;&lt;br /&gt;&lt;br /&gt;while allocating space for 2D arrays using new to read the elements&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int * val=new int[r*c] // r and c are no of rows and columns resp.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(int i=0; i%26lt;r; i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(int j=0; j%26lt;c; j++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;cin%26gt;%26gt;val[i*c+j];   //  what does this statement do?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;my doubt is why not A[i] [j]?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;what does this statement do?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C++ pointers and 2D arrays?&lt;br&gt;You haven't actually allocated a 2d array: you've allocated a 1d array of size r*c.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Consequently, you need to do some math to convert your 2d coordinate into a 1d index.  i*c+j converts your (r,c) coordinate into a unique index.  You can see how this works simply by trying various numbers:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(0, 0) = 0*c+0 = 0&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(1, 0) = 0*c +1 = 1&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(0, 1) = 1*c + 0 = c&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(1, 1) = 1*c+1 = c + 1&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In this way, every possible 2d coordinate gets mapped to an index between 0 and r*c.&lt;br&gt;Reply:The statement assigns the user input to the array in the position indicated by i, c+j.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4888192256869178515?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4888192256869178515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers-and-2d-arrays.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4888192256869178515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4888192256869178515'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers-and-2d-arrays.html' title='C++ pointers and 2D arrays?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5894984182552670721</id><published>2009-07-12T21:05:00.001-07:00</published><updated>2009-07-12T21:05:27.720-07:00</updated><title type='text'>Write a program to demonstrate huge pointer and far pointer? Also describe what is TSR program in C?</title><content type='html'>Now?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Write a program to demonstrate huge pointer and far pointer? Also describe what is TSR program in C?&lt;br&gt;Look for book "Writing TSR in C" book by Indian Author Yashwant Kanetkar. It should have both the answers for you. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;you can buy it form following link&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://survey-monkey.blogspot.com/&gt;survey monkey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5894984182552670721?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5894984182552670721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/write-program-to-demonstrate-huge.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5894984182552670721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5894984182552670721'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/write-program-to-demonstrate-huge.html' title='Write a program to demonstrate huge pointer and far pointer? Also describe what is TSR program in C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6630184977088861087</id><published>2009-07-12T21:05:00.000-07:00</published><updated>2009-07-12T21:05:10.608-07:00</updated><title type='text'>In c++,why can't we assign a void pointer to an int type pointer?</title><content type='html'>do this&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void* vp;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int*    ip;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ip=(int*)vp;&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;In c++,why can't we assign a void pointer to an int type pointer?&lt;br&gt;Because they're different data types, one is a pointer to an int, and the other is not :-)  They're all just memory addresses though, so if you know what you're doing then you can typecast one to the other.&lt;br&gt;Reply:Because doing so, without a really good reason, is a very bad idea.  The compiler warning / error for that attempted assignment is a safeguard to keep programmers from making silly mistakes.  If you get this kind of a message, it is very likely that your program's data design is flawed or poorly thought out.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;However, C++ will allow you to make that kind of assignment using an explicit typecast.  Using a typecast is the same as telling the compiler that you know what you are doing, and take full responsibility for the consequences of that kind of assignment and any side effects which may occur.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6630184977088861087?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6630184977088861087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/in-cwhy-cant-we-assign-void-pointer-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6630184977088861087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6630184977088861087'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/in-cwhy-cant-we-assign-void-pointer-to.html' title='In c++,why can&apos;t we assign a void pointer to an int type pointer?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-9190118566455171693</id><published>2009-07-12T21:04:00.003-07:00</published><updated>2009-07-12T21:04:53.272-07:00</updated><title type='text'>Help on C++ declarations (pointers and arrays)?</title><content type='html'>I have a homework assignment and the first question has 4 parts. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;It says "Explain the meaning of the following C++ declarations."&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(a) double *a [n];  &lt;br&gt;&lt;br /&gt;&lt;br /&gt;(b) double (*b) [n]; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;(c) double (*c [n]) (); &lt;br&gt;&lt;br /&gt;&lt;br /&gt;(d) double (*d()) [n]; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;That is the question and here are my guesses.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(a) -  I'm thinkg that this is just an array of size n with each element being a pointer to a double.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(b) - maybe its an array of size n with the first element as a pointer to a double.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(c) - this is a prototype of a function that returns an array of size n with each element being a pointer to a double.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(d) - this one is really confusing. I think it might be an array of size n of function d pointing to a double.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Please give me some help. I am not very certain on any of those answers. Thanks a lot for everything.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Help on C++ declarations (pointers and arrays)?&lt;br&gt;It's tricky to read these types of declarations&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;a is an array of n pointers to doubles&lt;br&gt;&lt;br /&gt;&lt;br /&gt;b is a pointer to an array of n doubles&lt;br&gt;&lt;br /&gt;&lt;br /&gt;c is an array of n pointers to functions that return doubles&lt;br&gt;&lt;br /&gt;&lt;br /&gt;d is a function returning a pointer to an array of n doubles&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Here is the trick.  Look at the variable name. Then look at the next element to the right. You can't jump out of any parentheses though. Say what you see, and then look left (but again, don't jump out of parentheses). Say what you see, and jump out a level.  Repeat.  It's just a matter of look right, look left, jump out, look right, look left, jump out, etc.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So to go through those in more detail:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;1)  Start at 'a'. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;Look right and say "array of size n". &lt;br&gt;&lt;br /&gt;&lt;br /&gt;Look left and say "pointers to". &lt;br&gt;&lt;br /&gt;&lt;br /&gt;Look right and that's the end of the statement, so don't say anything.&lt;br&gt;&lt;br /&gt;&lt;br /&gt; Look left again, and say "double". &lt;br&gt;&lt;br /&gt;&lt;br /&gt;Then putting it all together, a is an array of size n pointers to doubles.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;2) Do it the same way:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;"b is" &lt;br&gt;&lt;br /&gt;&lt;br /&gt;look right - hit parentheses, can't do anything.  &lt;br&gt;&lt;br /&gt;&lt;br /&gt;look left - "a pointer to".&lt;br&gt;&lt;br /&gt;&lt;br /&gt;jump out a level.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;look right - "array of n"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;look left - "doubles"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Maybe I haven't explained it as well as I could have, but here's a website that has a lot of examples, and explains the rule in better detail.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.antlr.org/wiki/display/CS652/...&lt;br&gt;Reply:O wow, I'm actually in the same class (stumbled onto here by way of Google).  I was having trouble with this one myself and just wanted to say thanks for asking it here and thanks to the guy who answered above me, very nice detailed answer.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-9190118566455171693?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/9190118566455171693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/help-on-c-declarations-pointers-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/9190118566455171693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/9190118566455171693'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/help-on-c-declarations-pointers-and.html' title='Help on C++ declarations (pointers and arrays)?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2906142048714818008</id><published>2009-07-12T21:04:00.002-07:00</published><updated>2009-07-12T21:04:39.759-07:00</updated><title type='text'>Why can't functions in C return an Array without using the pointer method??</title><content type='html'>Because the C language has no built-in "Array" data type.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  To mimic a "collection of things" in C, the address (pointer) to the first in a line of items is passed around.  This is also very efficient, since moving large amounts of memory as a single array of like types is much slower than simply passing around the memory address of the items, and they stay put.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; To know the end of an array, either the length is also passed around, or as with strings, a terminating null is appended to the end.  This is quite convienent, so that in many programs, one will find an array has a NULL (0) in it's last position instead of a full data type (say, if you were using an array of custom struct's).  this allows one to skip passing the array pointer and the length everywhere.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; Arrays are traversed by the compiler's machine code by knowing 2 things:  The index you're looking for, and the size of each item in the array.  By adding up the bytes of a single entry, say "size", it performs the simple math of "index * size" to jump to the position in memory that is Array[index].&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; In C, arrays are no different than performing this arithmetic yourself (called pointer arithmetic):  If you have a an array:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; SomeDataType* arraySDT = malloc( sizeof(SomeDataType) * 100);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  [ 100 spaces reserved for something of "SomeDataType" size]&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; ...then...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; SomeDataType* pointToPosition10 =  arraySDT * (sizeof(SomeDataType) * 9);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; SomeDataType* pointAlsoToPosition10 = arraySDT[9];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; both of the above are equivalent, since in the first you do the math to jump ahead of the base pointer into the array's memory.  In the second, the compiler has done the math.  Using the second syntax is advised.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;[ remember, to subtract one from that position you want since all arrays begin at position 0. ]&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Why can't functions in C return an Array without using the pointer method??&lt;br&gt;It has to deal with the origins of C, and lower level assembly language. C was originally meant to be an abstracted cross platform version of ASM with a lot of simplification. Now when a function returns in C (as with most programming languages) on x86 processors, the return value is set in the eax register (a register is a 32 or 64 bit peice of memory that the processor has, it only has a few, but they work extremely fast, much faster than computer ram).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now, the register can either contain a value, or the address of data. The reason why you can't return an array, is because you're controlling the computer at a much lower level than you realize (unlike PHP or VB). Doing things at a lower level give you control over how things are implemented, and allow you to greater refine your code for speed.&lt;br&gt;Reply:That would be too much data to put on the Return stack.   The pointer method is a much better way to control and conserver memory space, and prevent programming errors caused by leaky RAM segments and left over memory space that is left allocated. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Good luck&lt;br&gt;Reply:Thats because an when you reference an array name you are actually referencing a memory location.The only way to reference a memory location is via a pointer,hence you will need to use a pointer to access the value stored in the array&lt;br&gt;Reply:Unlike in more modern languages, C does not actually contain a what we know today as an array. Rather, it is a smoke-and-mirrors trick by the compiler involving pointer arithmetic using given offsets. Thus, the only way to reference an array (that is, a chunk of memory that can be accessed in a convenient way) is by passing the base pointer.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2906142048714818008?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2906142048714818008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-cant-functions-in-c-return-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2906142048714818008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2906142048714818008'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-cant-functions-in-c-return-array.html' title='Why can&apos;t functions in C return an Array without using the pointer method??'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4378834133978887747</id><published>2009-07-12T21:04:00.001-07:00</published><updated>2009-07-12T21:04:21.435-07:00</updated><title type='text'>C Programming: How do I set one pointer to a structure equal to an existing one?</title><content type='html'>If you just want Action to point to Enemy, you do:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Character *Action;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Action = Enemy;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If you want a real copy you need to reserve memory for Action and do the copy like this:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Character Action;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;memcpy(%26amp;Action, Enemy, sizeof(Character));&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C Programming: How do I set one pointer to a structure equal to an existing one?&lt;br&gt;Don't do it! Use a variable instead. I had to virtually offer a colleague violence when he insisted making the "pointer to a pointer" thing work, he was at it for 3 days. It took him 45mins with a variable once he saw the light. You've got buckets of memory these days, use it.&lt;br&gt;Reply:No problem&lt;br&gt;&lt;br /&gt;&lt;br /&gt;typedef struct&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   int a;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   int b;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}myType;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;myType *x;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;myType *y;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;x = (myType *)malloc(sizeof(myType));&lt;br&gt;&lt;br /&gt;&lt;br /&gt;y = (myType *)malloc(sizeof(myType));&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;x-%26gt;a = 3;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;x-%26gt;b = 5;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*y = *x;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;that will copy all of the x data into the y memory.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Your example has:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*Enemy = *Action;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;That's backward, you haven't assigned Action yet.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Also you haven't given it memory to Enemy or Action.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;you need to malloc space for both.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The other poster is correct too.  You can either copy the&lt;br&gt;&lt;br /&gt;&lt;br /&gt;structure using the derefernce "*" or using memcpy.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Oops, sorry you're just assigning the ptr for Enemy still need memory for action.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;---&lt;br&gt;&lt;br /&gt;&lt;br /&gt;just did this in Visual Studio express, it works fine:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include "stdafx.h"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include "string.h"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include "stdlib.h"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;typedef struct Man {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char Name[31];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int Number;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}Character;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int _tmain(int argc, _TCHAR* argv[])&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   Character Bob;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   Character *Enemy;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   Character *Action;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; Bob.Number=110;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    strncpy(Bob.Name, "Bob", 31);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   Enemy=%26amp;Bob;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   Action = (Character *)malloc(sizeof(Character));&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   *Action = *Enemy;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt; return 0;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;Reply:Try here for info&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.techtutorials.net/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.rickmaybury.com/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.theeldergeek.com/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.good-tutorials.com/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.digitaljuice.com/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.tutorialkit.com/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.codestyles.com/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.sitecube.com/website/promo_bw...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://10online-survey.blogspot.com/&gt;online survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4378834133978887747?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4378834133978887747/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-programming-how-do-i-set-one-pointer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4378834133978887747'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4378834133978887747'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-programming-how-do-i-set-one-pointer.html' title='C Programming: How do I set one pointer to a structure equal to an existing one?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6099975163665408624</id><published>2009-07-12T21:04:00.000-07:00</published><updated>2009-07-12T21:04:08.765-07:00</updated><title type='text'>Why should i use int pointer to store integer value in c?</title><content type='html'>Let me tell you what happens if you don't.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Say you are on a machine where an int is 32 bits(4bytes).  And a short is 16 bits(2 bytes) and you do this.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int y = 10;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;short *z = (short *)%26amp;y;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*z = 12;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Well the location that is storing the y has 4 bytes, but because you are using z a short (2 bytes) pointer it transfers only 2 bytes.  In other words the type of pointer decides how many bytes to copy, not the location (y).  This also affects things like z++ moves to the memory location two bytes higher, where as if z had been a integer pointer it would have moved it by 4 bytes.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;By the way I used (short *) above, because if I didn't the compiler would complain that I'm trying to do this most likely bad thing.  There are cases where a programer might actually want to only transfer only two bytes so C lets you tell the compiler to accept this, with this syntax, which is a cast, as in cast (change) the integer pointer into a short pointer.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6099975163665408624?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6099975163665408624/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-should-i-use-int-pointer-to-store.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6099975163665408624'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6099975163665408624'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/why-should-i-use-int-pointer-to-store.html' title='Why should i use int pointer to store integer value in c?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4241005787734416688</id><published>2009-07-12T21:03:00.003-07:00</published><updated>2009-07-12T21:03:50.317-07:00</updated><title type='text'>What is null pointer, far and near ponters in c language?</title><content type='html'>A null pointer is one which doesnot refer to &lt;br&gt;&lt;br /&gt;&lt;br /&gt;any thing .&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Far pointer : it refers to an address which not in the same &lt;br&gt;&lt;br /&gt;&lt;br /&gt;segment where pointer is defined.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Near pointer : refers to an adress in the same segment where&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the pointer is defined&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;What is null pointer, far and near ponters in c language?&lt;br&gt;NULL pointer points to a place in memory that cannot be accessed.&lt;br&gt;Reply:In C/C++, NULL is generally represented with a 0.  The NULL pointer points to nothing.  So any public / externally accessible function or method that accepts a pointer should check for NULL.  Example:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#define NULL 0&lt;br&gt;&lt;br /&gt;&lt;br /&gt;void printMe(const char * str)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;if( str == NULL ) return;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%s\n", str);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Expanding on the previous poster's answer:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Nowadays, the ideas of "near" and "far" pointers don't mean a thing unless you're writing embedded software on an old processor.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The notions of "near" and "far" pointers are remnants of Intel's segment:offset addressing on their 16-bit processors.  A segment and offset were used to construct a complete address.  The segment is shifted left 4 bits and the offset is added to come up with a 20 bit address (which limited addresses a total 1M addressable space).  The offset referenced a 64K area of memory (the most that can be addressed in 16 bits).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;An example of building a segment:offset address would be:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;segment = 0x1234&lt;br&gt;&lt;br /&gt;&lt;br /&gt;offset = 0x2222&lt;br&gt;&lt;br /&gt;&lt;br /&gt;physical address =&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(segment %26lt;%26lt; 4) + offset = 0x12340 + 0x02222 = 0x14562&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Intel made it more efficient to access data within a 64K segment by including a register that defined the "current" segment.  Near addressing required a 16-bit offset and was assumed to reside in the "current" segment.  This would be a NEAR pointer.  So NEAR pointers are only 16 bits.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If you need to access data outside the "current" 64K segment, you had to construct a segment:offset pair.  This was a FAR pointer.  A FAR pointer required 32 bits: a segment and an offset (even though the FAR pointer could still only access up to 24 bits, as defined by the segment:offset architecture).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;One disadvantage is that it was inefficient to create data structures that were larger than 64K.  Another disadvantage was that pointer arithmetic was a nightmare.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The "near" and "far" pointers started to disappear with the introduction of the 80386, Intel's first 32-bit processor.  The '386 defined "protected" mode, where full 32-bit addresses could be used (DOOM ran in protected mode :)).  However, to maintain compatibility with the vast amount of DOS software that was still around, the '386 retained segment:offset addressing.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4241005787734416688?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4241005787734416688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-null-pointer-far-and-near.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4241005787734416688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4241005787734416688'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-null-pointer-far-and-near.html' title='What is null pointer, far and near ponters in c language?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4344626108455080916</id><published>2009-07-12T21:03:00.002-07:00</published><updated>2009-07-12T21:03:38.460-07:00</updated><title type='text'>I dont understand pointer to pointer and structure in structure in c?</title><content type='html'>for whe use it  ans whats the advantge&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;I dont understand pointer to pointer and structure in structure in c?&lt;br&gt;I assume that you know Pointers already. Now Pointer to Pointer means "A pointer holds the address of another another pointe". In C, C++ pointer to pointer is declared as &lt;br&gt;&lt;br /&gt;&lt;br /&gt; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *p; //simple pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int **q=%26amp;p //pointer to pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In practical situtation like O.S development programers required to handle memory(both RAM and HDD) frequently and mater of sense is not the value stored in memory but important is address of memory location. Therefore pointers to pointers are used. Pointer to pointer  and structutre to structure mainly used in Data Structures like Linked Lists.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Structures are collection of disimilar datatypes.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;eg:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct employee&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    int empcode;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    char ename[20];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    float salary;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct manager&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   struct emoplyee; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;    char dept[20];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;Reply:It used to be that using pointers was an economical use of memory in C programming. These days it's less important and using a regualr variable can save you a lot of grief. There used to be saying in C programmer circles that "using pointers allows you to shoot yourself through the foot, using pointer to pointer structures allows you to shoot yourself through the foot and not know which foot". Example, colleague of mine was programming a small text editor in C and spent 3 days trying to get a a p2p structure to work. After virtually offering him violence (he'd been indoctrinated into pointers when he was learning C programming) I persuaded him to use a regular variable and he had his function sorted within 45 minutes.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4344626108455080916?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4344626108455080916/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-dont-understand-pointer-to-pointer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4344626108455080916'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4344626108455080916'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-dont-understand-pointer-to-pointer.html' title='I dont understand pointer to pointer and structure in structure in c?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-7005756143009241096</id><published>2009-07-12T21:03:00.001-07:00</published><updated>2009-07-12T21:03:21.826-07:00</updated><title type='text'>C programming - Consider an int variable x and consider a pointer float* p=(float*)&amp;x pointing to x.?</title><content type='html'>Consider an int variable x and consider a pointer float* p=(float*)%26amp;x pointing to x. If we store a float value 2.35 in x directly using x = 2.35 or indirectly using *p=2.35, will we get the same bit pattern stored in x in both cases or instead different patterns? Explain your answer, just “Yes” or “No” is not sufficient.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C programming - Consider an int variable x and consider a pointer float* p=(float*)%26amp;x pointing to x.?&lt;br&gt;The bit pattern for x = 2.35 is not the same as *p = 2.35.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This is because you defined x as a int and when you assign 2.35 (a float) to x (an integer) the C language will automatically cast the value of 2.35 to an int.  So x will be assigned the value of 2.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;However, since you defined p as a pointer to a float and since x is 4 bytes and a float is 4 bytes, you can actually use a pointer to a float to put a floating point value in an integer variable.  Just don't expect to be able to look at the variable x and get anything meaningful.&lt;br&gt;Reply:first of all float pointer can't hold address of integer variable so its no question about storing value any way&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://salary-survey2.blogspot.com/&gt;salary survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-7005756143009241096?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/7005756143009241096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-programming-consider-int-variable-x.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7005756143009241096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7005756143009241096'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-programming-consider-int-variable-x.html' title='C programming - Consider an int variable x and consider a pointer float* p=(float*)&amp;amp;x pointing to x.?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-627696798067136052</id><published>2009-07-12T21:03:00.000-07:00</published><updated>2009-07-12T21:03:03.061-07:00</updated><title type='text'>How to make a funcition that returns a pointer to the head of a list in C?</title><content type='html'>Hi i need to write a funcition called install, its takes as arguments&lt;br&gt;&lt;br /&gt;&lt;br /&gt;1- a vector&lt;br&gt;&lt;br /&gt;&lt;br /&gt;2-a number&lt;br&gt;&lt;br /&gt;&lt;br /&gt;3-a list called next_level&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;so heres where it get kinda weird:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;next_level is a list comprising of elements that are { vectors, with&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pointers}, defined by the following struct&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;typedef struct wnode {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int weight[maxrank+1];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct wnode *next;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;} WEIGHTPTR,*WEIGHTPTR;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now install is a funcition that returns a pointer to the frist vector&lt;br&gt;&lt;br /&gt;&lt;br /&gt;in the list, Can anyone give the code to define this funcition.?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Thanks:&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How to make a funcition that returns a pointer to the head of a list in C?&lt;br&gt;I am not sure how you are making the list, I understand about the elements in the list.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You could do a number of things:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Firstly, not to make the struct definition different, you could create a list structure.  This struct could have a typedef like:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;typedef struct list {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct wnode *first;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Then when passing the list to the function, the function can return the 'first' pointer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Second way, create a double ended list, but this changes the wnode struct.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;typedef struct wnode {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int weight[maxrank+1];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct wnode *next;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct wnode *prev;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;} WEIGHTPTR, *WIEGHTPTR&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You could then transverse backwards through the list to get to the first element.  The first element should have a null pointer as the 'prev' element, and the last element should have a null pointer as the 'next' element.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The first seems easier, but will require you making a list, and filling it appropriately.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The second may change what you need to do, and also may have no relevance to what you are trying to do.  An element of the list is not being passed into the function, only the list is.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-627696798067136052?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/627696798067136052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-make-funcition-that-returns.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/627696798067136052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/627696798067136052'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-make-funcition-that-returns.html' title='How to make a funcition that returns a pointer to the head of a list in C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-3458373978908006207</id><published>2009-07-12T21:02:00.003-07:00</published><updated>2009-07-12T21:02:47.104-07:00</updated><title type='text'>How do you return a pointer from a function in c++?</title><content type='html'>Just assign the  desired variable to the pointer that was used in the function.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How do you return a pointer from a function in c++?&lt;br&gt;int* func1()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int* a;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return a;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-3458373978908006207?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/3458373978908006207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-do-you-return-pointer-from-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3458373978908006207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3458373978908006207'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-do-you-return-pointer-from-function.html' title='How do you return a pointer from a function in c++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-1147934362279375961</id><published>2009-07-12T21:02:00.002-07:00</published><updated>2009-07-12T21:02:31.447-07:00</updated><title type='text'>Du any 1 have C or C++ program to bring mouse pointer an handle all event handling techniques...?</title><content type='html'>U're using DOS?... If so, I guess it's a lil bit hard, Simply check this out: http://programmersheaven.com&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Good Luck;)&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-1147934362279375961?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/1147934362279375961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/du-any-1-have-c-or-c-program-to-bring.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1147934362279375961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1147934362279375961'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/du-any-1-have-c-or-c-program-to-bring.html' title='Du any 1 have C or C++ program to bring mouse pointer an handle all event handling techniques...?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-1747419459774065057</id><published>2009-07-12T21:02:00.001-07:00</published><updated>2009-07-12T21:02:18.462-07:00</updated><title type='text'>How to create a word using a pointer to some dynamic memory in c++?</title><content type='html'>"we will not assume anything about the maximum length word that might be processed. So, a word will not be an array of some constant size, but rather a pointer to some dynamic memory where the word is stored. "&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The only way I know how to make a word is through char arrays.  How exactly can i do it the other way?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How to create a word using a pointer to some dynamic memory in c++?&lt;br&gt;There are specialized string classes in most C++ variants today, but this sounds like it's talking more about the old C memory allocation functions:  malloc and calloc, and their cohort free.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In general, you have to determine how much memory to allocate (how big the word is, plus one character for the null byte string terminator), then use malloc or calloc to give you a chunk of memory that big.  Usually, you'll have read the word in as a part of a string, say a line of keyboard input, and are splitting the whole string up into pieces.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In general, the code will look something like this:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char* pWord = NULL;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// Now read in the line and cycle through it looking for word separators.  For each word, do the following:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pWord = calloc( size_of_word, sizeof( char )); // calloc clears the memory to zero -- a handy side effect&lt;br&gt;&lt;br /&gt;&lt;br /&gt;strncpy( pWord, point_in_line_where_word_starts, number_of_chars_in_word )&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;When you're done using the word(s), you call free to return the space to the system.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Hope that helps.&lt;br&gt;Reply:try this&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *pWord;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;then make a work&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char i = 'Hello';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*pWord = i; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Why not make a *pWord a Free Store memory;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;like this&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char i = 'Hello';&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *pWord = new char;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;then u can asign it to any word u want like this.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*pWord = i;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If you want to asign it to different value u can&lt;br&gt;&lt;br /&gt;&lt;br /&gt;delete pWord;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*pWord = new char;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;then again it. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I think this is right.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://surveys4.blogspot.com/&gt;surveys&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-1747419459774065057?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/1747419459774065057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-create-word-using-pointer-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1747419459774065057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1747419459774065057'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-create-word-using-pointer-to.html' title='How to create a word using a pointer to some dynamic memory in c++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-7320828497991667537</id><published>2009-07-12T21:02:00.000-07:00</published><updated>2009-07-12T21:02:02.287-07:00</updated><title type='text'>C++ pointers?</title><content type='html'>im currently try to teach myself c++ my question is about pointers i understand how to use but i don't get why you would use them what dose it matter where something is stored in the memory or that you can access the things its pointing to by putting a * in front of it why wouldn't you just manipulate the object directly or am i missing something here? thanks&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C++ pointers?&lt;br&gt;You have come upon a very complex thing. Pointers give the best of us headaches.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;They aid in memory improvements, and they can allow a program to change large amounts of information "on-the-fly"&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If you are not working on Operating Systems, or working on large programs, then you don't need to worry about it. That's the short of it.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I've never had to use them myself because what I am trying to do is not that big.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Hope that helps.&lt;br&gt;Reply:C++ began as a superset of C.  Whether it is still a superset of C is debated, but it is probably not a separate language: you can access C's libraries and include files in a C++ program and also any of its design features.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The big advantage comes when you don't know how much data you are going to be working with and won't know until run-time.  With a corporate database, for example, a company is always looking for new customers, and some customers move on.  While some companies can do very well with a database which fixes a maximum size for the number of records they use, it's easier to use new CustomerRecord workrecord and delete workrecord on an as-needed basis.  In other words, you code an algorithm for increasing and decreasing the size of the database rather than hard coding the size of the database into your program.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;My background is in C.  I haven't totally made the conceptual shift to C++ (though I don't have a problem with objects) and I don't want to.  &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Part of C's design specifications is that everything is passed by value except arrays.  In other words when you send an int, float or other variable to a function, it creates a new variable, assigns it the same value as the variable it was sent, and works with that, not with the old variable.  When the function ends control passes back to the calling function where the changes and manipulations you made have no effect.  In C the only way to pass by reference is to send a pointer to the memory address where the value you want to change is stored.  The compiler still creates a new variable, but since it only stores the memory address, its destruction when it goes out of scope will not cause the value at the end of the function to revert to what it was before.  C++ does have a pass-by-reference operator, which is the same as the address-of operator in C: %26amp;.  While it does make things a little more convenient for a hurried programmer, it also makes writing bad code a little easier, so not everyone uses it.  Why make it easy when you should be thinking very hard about what you are doing with it anyhow?&lt;br&gt;Reply:One of the advantages of pointers are when u want to use an array as an argument of a function. if u give the array itself to the function %26amp; change it in the function, there will be no change in the main array but when you give the pointer of that array as the argument, changes will happen directly on your array %26amp; this is a very important use in programming! If not satisfied u can ask me for more !&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-7320828497991667537?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/7320828497991667537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7320828497991667537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7320828497991667537'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/c-pointers.html' title='C++ pointers?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-3105853127397605072</id><published>2009-07-12T21:01:00.002-07:00</published><updated>2009-07-12T21:01:44.962-07:00</updated><title type='text'>Can someone explain to me what is copy constructor, operator overloading, pointer and reference in C++?</title><content type='html'>A copy constructor for a class is a constructor that has an object of the class as its only parameter. It makes a new object that is a duplicate of the original object.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Operator overloading is defining new meaning for existing operators. For example, string classes usually overload the arithmetic "+" operation to mean string concatenation.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A pointer is a variable that holds the address of another variable.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A reference is another name for an existing object. If you have an object A, and you create an object B, which is a reference to A, when you modify B, you are actually modifying A.  &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;When you have a subroutine, and you pass it a variable as a parameter, what the subroutine gets is a copy of the original value. If you changed the parameter in the subroutine, it does nothing to the original variables value.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If, however, you pass a reference to the variable, then any changes you make to the parameter in the subroutine are made to the original value.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Can someone explain to me what is copy constructor, operator overloading, pointer and reference in C++?&lt;br&gt;http://cplus.about.com/od/beginnerctutor...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;try this link&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-3105853127397605072?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/3105853127397605072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-someone-explain-to-me-what-is-copy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3105853127397605072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/3105853127397605072'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-someone-explain-to-me-what-is-copy.html' title='Can someone explain to me what is copy constructor, operator overloading, pointer and reference in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-8580350947401085016</id><published>2009-07-12T21:01:00.001-07:00</published><updated>2009-07-12T21:01:26.152-07:00</updated><title type='text'>In C++, how does an uninitialised pointer crash a system....??</title><content type='html'>Mark F's answer is very good and correct but as for how the uninitialized pointer can crash a system, not just a "process" running on a system, the short answer is it can't or it shouldn't be able to. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;On a modern operating system that is not malfunctioning the reason a process "crashes" when trying to access memory it does not "own" is this "crash" is the operating system "protecting" itself from being corrupted by the illegal memory access via the uninitialized pointer (you may have heard of protected mode in x86 processors; this is what it's for).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;That said, many of the security holes found by hackers in Microsoft Windows operating systems were exploits using pointers in to supposedly invalid memory that the operating system didn't properly detect. Some of these memory regions have access levels greater then the user space (application ring) and once a program is loaded into this type of memory it can corrupt the system and cause it to crash.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;In C++, how does an uninitialised pointer crash a system....??&lt;br&gt;By itself, an uninitialized pointer is harmless.  Try to use that pointer and your program will most likely crash, or at least not behave correctly because you are working with random data.  Usually uninitialized pointers point to memory the application is not allowed to access, so the operating system says the program must shut down because it performed an illegal operation.  It's rare that bad pointers will totally crash a system.&lt;br&gt;Reply:hii dear &lt;br&gt;&lt;br /&gt;&lt;br /&gt;u have a class in c++ in which there is a pointer . u had not created any constructor or created but not initialised the pointer in that constructor then a default value will be attached with your pointer and that is a NULL.u can say it a null reference .its not the real addres of machine's memory actually a null reference means it is pointing to nowhere .when u will try to use it it will throw an exception that it is a NULL reference it is pointing to nowhere or clearly saying it will say illegal address accessing  at this stage the if u had installed any exception handler for this will be called.If u had not installed the exception handler then default exception handler of operating system will be called which due to security reason will close the application (or ur application crashes).I want to point one thing here ur application crashes not the system crashes.System will crash in that situation where u r working in kernel area and done something wrong.but normally we work in user so there is no chance(rare chance) for system crash.&lt;br&gt;Reply:The operating system works in conjunction with the hardware to keep track of which applications are allowed to use which parts of memory, and the way in which they're allowed to use it (i.e. data, code etc). An uninitialized pointer usually contains either a random value or the value 0, neither of which are likely to point to an area of memory that the task is allowed to use. Attempting to read from or write to this part of memory causes the CPU to automatically trigger a hardware interrupt which the operating system detects, it then "crashes" (i.e. terminates) the offending application as a precaution.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-8580350947401085016?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/8580350947401085016/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/in-c-how-does-uninitialised-pointer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8580350947401085016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8580350947401085016'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/in-c-how-does-uninitialised-pointer.html' title='In C++, how does an uninitialised pointer crash a system....??'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4213693625733790605</id><published>2009-07-12T21:01:00.000-07:00</published><updated>2009-07-12T21:01:14.245-07:00</updated><title type='text'>I want a objects destructor to call a method of another object to delete its pointer to me. Its in C++?</title><content type='html'>The other objects has a list of pointer to objects like the main, the main objects tell the other its addres and the object deletes it from its list&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;I want a objects destructor to call a method of another object to delete its pointer to me. Its in C++?&lt;br&gt;Here's a brief, overly simple example of that using cars and garages.  The Car's destructor removes itself from the garage. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;class car&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;     ~car() { myGarage-%26gt;deleteCar(this); }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    Garage* myGarage;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;class Garage&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   public:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    list%26lt;Car*%26gt; myCars;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;    void deleteCar(Car* carToDelete) { myCars.remove(carToDelete);   }&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://survey-monkey.blogspot.com/&gt;survey monkey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4213693625733790605?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4213693625733790605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-want-objects-destructor-to-call.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4213693625733790605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4213693625733790605'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/i-want-objects-destructor-to-call.html' title='I want a objects destructor to call a method of another object to delete its pointer to me. Its in C++?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-387745867980655892</id><published>2009-07-12T21:00:00.003-07:00</published><updated>2009-07-12T21:00:56.352-07:00</updated><title type='text'>What is differnce between pointer and referance in c?</title><content type='html'>A pointer points as a reference, and a reference references a pointer, except in the case of a reference pointer which points to a reference to a reference of a pointer.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;What is differnce between pointer and referance in c?&lt;br&gt;same&lt;br&gt;Reply:pointers can be called as naked reference.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;when you say its reference means you are actually operating on that variable. it is a kind of alias&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;where as in case of pointer, if pointer is pointing to something, and now you change that pointer to point something else, your original variable will still there unchanged.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;but in case of reference, once you make a reference you can not do a un-reference. Cannot remove a reference once it referred to something.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;references are created while initialization only, where as you can use pointer at any moment.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;i hope now its clear what is reference and what is pointer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int x=10;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *p=0;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int %26amp;y=x;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;now p = %26amp;x;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;if you do p=NULL, value of x will not change.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;if you do y=0;, actually value of x will become 0&lt;br&gt;Reply:You can consider them to be the same.&lt;br&gt;Reply:A pointer is a variable that stores the memory address of another object.  A reference IS the memory address of an object.  You can think of a pointer as a variable that represents a reference.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For instance:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{ &lt;br&gt;&lt;br /&gt;&lt;br /&gt;int myNumber = 14;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *number = %26amp;myNumber;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In this example, we create two variables.  "myNumber" is an integer variables that we set equal 14.  "number" is a pointer to an integer variable, that we set equal to "%26amp;myNumber".  "%26amp;myNumber" is the memory reference to the variable "myNumber".&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The major difference in using pointers vs. references is that a pointer can store a null value.  A reference must identify a valid object.  Also, the value of a pointer can change.  We can make it point to a different reference later on in the program.  A variable's reference is constant and cannot be changed.&lt;br&gt;Reply:A reference is the actual memory address of the variable. Passing things into functions by reference means you are actually sending the memory address, and therefore make that variable modifiable inside the function (instead of just passing it in by value, which creates a copy of that variable's value for its own use)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A pointer has its own memory reference like a normal variable, but its actual value is the reference to another property's memory address, so that when you look at a pointer's value, it is actually the memory address of the property its pointing to.&lt;br&gt;Reply:allmost about the same thing&lt;br&gt;Reply:A pointer contains some address that refers to the location of an object. Hence, a pointer points to an object. A reference is an alias to an object. In that sense, a reference IS an object itself. References are not pointers. Let me repeat. References are not pointers. You do not dereference them. You do not reseat them. You do not use pointer logic with them. They are objects themselves.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Consequently, pointers and references are NOT the same. The compiler may resolve a reference to a pointer or the object itself. That is not your concern.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(trueextremeicon) %26gt; A reference is the actual memory address of the variable. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;No. It's not. It's the object itself, for all purposes. You do not dereference a reference.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26gt; Passing things into functions by reference means you are actually sending the memory address &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;No. It means that you are referring to the object itself, not a temporary copy. The compiler may resolve it by passing a memory address. You do not care.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(marbledog) %26gt; A reference IS the memory address of an object &lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;No. It is not. A pointer contains some address that on dereferencing gets you the object. A reference is the object itself, for all purposes. You do NOT dereference a reference.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;See http://www.parashift.com/c++-faq-lite/re... .&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-387745867980655892?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/387745867980655892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-differnce-between-pointer-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/387745867980655892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/387745867980655892'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-differnce-between-pointer-and.html' title='What is differnce between pointer and referance in c?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4524637890468760420</id><published>2009-07-12T21:00:00.002-07:00</published><updated>2009-07-12T21:00:38.908-07:00</updated><title type='text'>What is the difference between function returning pointer,function pointer &amp; pointer to function in C lang??</title><content type='html'>A function that returns a pointer returns a reference to a memory address.  A function that returns a pointer should NOT define the pointer or it will disappear when the function goes out of scope. A lot of times the pointer is passed into the function as a parameter, modified and returned.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A prototype for a function that returns a pointer looks like: &lt;br&gt;&lt;br /&gt;&lt;br /&gt;aPtr * funcReturnsPtr( SomeType * aPtr);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A function pointer is a pointer that points to the address of a function.  That variable is a pointer to a function.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Here's an example of a variable pointing to a function:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;float result = pt2Func(a, b);&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;What is the difference between function returning pointer,function pointer %26amp; pointer to function in C lang??&lt;br&gt;function returning pointer returns pointer value.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;function pointers are pointer variables having its value pointing to the address of any function.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pointers to function means that the arguments passed in the function are pointers.&lt;br&gt;Reply:char *Function1()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return "Hello";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *Function2()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return "World";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *  ((*function_pointer)());&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;function_pointer = Function1;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%s ", (*function_pointer)());&lt;br&gt;&lt;br /&gt;&lt;br /&gt;function_pointer = Function2;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%s\n", (*function_pointer)());&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;-----------------------&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In the above example Function1 and Function2 return pointers.  function_pointer is a pointer to a function that returns a character.  The output of the above program is&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Hello World.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A function pointer is a pointer to a function.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4524637890468760420?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4524637890468760420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-difference-between-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4524637890468760420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4524637890468760420'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-difference-between-function.html' title='What is the difference between function returning pointer,function pointer &amp;amp; pointer to function in C lang??'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2142366786877075125</id><published>2009-07-12T21:00:00.001-07:00</published><updated>2009-07-12T21:00:25.587-07:00</updated><title type='text'>How the data in list-array that saved in memory when I use data structure by c++ languege whit not pointer?I n</title><content type='html'>If you mean STL list, (can you be more specific of what type of list?)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;then you can prob. do something like&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(int i = 0; i %26lt; mylist.size(); i++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;  cout%26lt;%26lt;mylist[i]%26lt;%26lt;endl;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2142366786877075125?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2142366786877075125/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-data-in-list-array-that-saved-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2142366786877075125'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2142366786877075125'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-data-in-list-array-that-saved-in.html' title='How the data in list-array that saved in memory when I use data structure by c++ languege whit not pointer?I n'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-8412890524438386874</id><published>2009-07-12T21:00:00.000-07:00</published><updated>2009-07-12T21:00:07.245-07:00</updated><title type='text'>Using C how can i create a pointer to a pointer.?</title><content type='html'>I have a hard time to understand char **abc. Can somebody pls explain this. Tell me how this relate to a string. It is said that abc can be considered as an array. I don't have any idea about how this happens. I'm so confused. Pls explain. I knw some C.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Using C how can i create a pointer to a pointer.?&lt;br&gt;if you declare a string like&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *myString = "asd";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;then myString a pointer to a character. It contains the address of the memory location which contains the character 'a'. Subsequent memory locations (i.e Mystring+1, myString+2) contain the characters 's' and 'd'. Make sure you understand this much before proceeding.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now, a declaration like &lt;br&gt;&lt;br /&gt;&lt;br /&gt;char **abc;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;creates a pointer abc that points to (or contains the address of) a character pointer like myString above.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Pointers to pointers are like a treasure hunt games where the first clue tells you where the second clue is; and the second clue tells you where the treasure (data) is.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;:) Happy huting !!&lt;br&gt;Reply:Well first of all I don't think you would normally need to create a pointer to a string which would be a pointer to a pointer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;However it this is what you would like to do then lets simply create a string first:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char s1[] = "Able";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In the instance above s1 is a simple pointer. Assuming that the string s1 is located at memory address 1000 (for illustration purposes) the actual value of s1 would be 1000 demonstrated by:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%d", s1);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;However the string pointer s1 is stored elsewhere, say memory address 800. The breakdown of the structure would be :&lt;br&gt;&lt;br /&gt;&lt;br /&gt;s1[0] --%26gt; Memory location 1000 --%26gt; A&lt;br&gt;&lt;br /&gt;&lt;br /&gt;s1[1] --%26gt; Memory location 1001 --%26gt; b&lt;br&gt;&lt;br /&gt;&lt;br /&gt;s1[2] --%26gt; Memory location 1002 --%26gt; l&lt;br&gt;&lt;br /&gt;&lt;br /&gt;s1[3] --%26gt; Memory location 1003 --%26gt; e&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now to create a pointer to the you would code:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *p_s1 = %26amp;s1&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Lets assume p_s1 is stored at memory location 2000.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%d", p_s1); would then output 800 the address of the pointer s1, not the address of the string. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now if you wanted to output the value of the string you would do this syntax **p_s1:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Lets break this down to see what happens&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p_s1 gives 800 the address of our string pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*p_s1 gives 1000 the dereferenced value of our string pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26amp;p_s1 gives 2000 the memory address of p_s1 (not needed but hre to give reference)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;so then:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*p_s1 is equivilent to 1000 (what s1 points too) and &lt;br&gt;&lt;br /&gt;&lt;br /&gt;**p_s1 is equivilent to 64 (the character A) the dereferenced value of 1000 or s1&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Note the following is NOT a pointer to a pointer but gives an illustration of how pointers and string are commonly used.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This is the code of the ANSI C strlen() function:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int strlen(char *string)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   char *ptr = string; /* ptr is used to reference each char in           the string variable*/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   while (*ptr != '\0') ptr++;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;   return ptr - string;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This might be more of what you want to do instead of a pointer to a pointer. Hope this helps&lt;br&gt;Reply:"char **abc" means "char* abc[]" - or - "abc is an array of pointers to char - we don't know how many elements long".&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;...and now the windy version...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In C, you don't really have strings at all. The compiler does not know anything about strings.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;All you have is arrays of characters. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;What makes an array of characters behave as a string are the standard C library functions, which expect the end of the string to always be marked with a "nul" character, 0x00.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Moving on to arrays...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;When you declare an array you tell the compiler the name or symbol you want it to have, the type of data it will contain, and the number of elements. e.g. &lt;br&gt;&lt;br /&gt;&lt;br /&gt;int A[5];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now the compiler initially uses this information to allocate space for the array, in this case 5 * sizeof(int) bytes.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Everywhere it is referenced, however, the name A behaves exactly the same as (const int *).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For example if we have:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int A[5];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *p;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;We can say p = A; but we can't say A = p;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;We can say A[3], and we can say p[3]. No difference.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Furthermore we can do pointer arithmetic with p because we told the compiler what type of critter p can point to -- &lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(p+3) = 1;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;AND you can do pointer arithmetic on A (as an rvalue)...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*(A+3) = 1; -- same thing, see?  A+3 == %26amp;(A[3])&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Now some tricky stuff. If you think about it, p is an array you can move. It is like int p[] - where you know how big each element is, but not how many elements there are.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Let's assign:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p = A+3; ...so p points to A[3] ... p = %26amp;(A[3])&lt;br&gt;&lt;br /&gt;&lt;br /&gt;... p[0] is the same variable as A[3]&lt;br&gt;Reply:look this sample program  below&lt;br&gt;&lt;br /&gt;&lt;br /&gt;as you are aware *ch is used to denote a string or is a pointer to a string&lt;br&gt;&lt;br /&gt;&lt;br /&gt;** is a pinter to an array of strings&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;stdio.h%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{char *my,**mc, *names[]={"anil","antony","afsal"};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;my="Sam";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;mc=names;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%s\n",my);printf("%s\n",*mc++)...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%s\n",*mc++);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("%s\n",*mc);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;printf("Hello world\n");&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return (0);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;my is a string array&lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26gt;mc=names;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;**mc is pointer to an array of strings the *names[]&lt;br&gt;&lt;br /&gt;&lt;br /&gt;%26gt;*mc++&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*mc++ will pint to the next element on the string array *names&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;hope it is clear now&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://10online-survey.blogspot.com/&gt;online survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-8412890524438386874?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/8412890524438386874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/using-c-how-can-i-create-pointer-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8412890524438386874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/8412890524438386874'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/using-c-how-can-i-create-pointer-to.html' title='Using C how can i create a pointer to a pointer.?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-1062684827315113825</id><published>2009-07-12T20:59:00.003-07:00</published><updated>2009-07-12T20:59:51.529-07:00</updated><title type='text'>How to declare pointer to an array in C programming?</title><content type='html'>I am writting a program for a class and my tutor says that declaring a pointer to an array will make the program run better.  How do I do this?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How to declare pointer to an array in C programming?&lt;br&gt;%26gt; I am writting a program for a class and my tutor says that declaring a pointer to an array will make the program run better.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;You haven’t told me the context of the code, but I get a bad feeling with such a statement? Pointers make your program run better? What kind of statement is that?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I recommend you read up your book on pointer notation. No book? See http://www.cprogramming.com/tutorial/c/l...&lt;br&gt;Reply:myFunction(int someArray[]) {&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *arrayPtr = %26amp;someArray[0];&lt;br&gt;Reply:assuming your array is an integer array&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *pointer;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int int my_array[] = {1,2,3,4,5,6};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pointer = %26amp;my_array[0];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Which means, make an integer pointer. Make an integer array. Point the pointer to the address of the first item in the array.&lt;br&gt;Reply:From the very little C knowledge I have, you point to the first item in the array.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-1062684827315113825?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/1062684827315113825/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-declare-pointer-to-array-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1062684827315113825'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/1062684827315113825'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-declare-pointer-to-array-in-c.html' title='How to declare pointer to an array in C programming?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5679341993081898830</id><published>2009-07-12T20:59:00.002-07:00</published><updated>2009-07-12T20:59:37.129-07:00</updated><title type='text'>C/C++ pointers as strings?</title><content type='html'>I am a relative novice at C++, and I am trying to write a stack class that holds lines of text. I need to hold everything in pointers because I don't know the sizes of things, and I have one question. Do you have to use new or malloc to allocate adequate memory to a pointer, or will it act intelligently? For example will:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *string = new char;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;std::cin %26gt;%26gt; string;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;instead of:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *string = new char[100];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;std::cin %26gt;%26gt; string;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;possibly cause it to segfault or corrupt other variables (I know it will at least hold the data)? I haven't had that happen before, but just to make sure...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;C/C++ pointers as strings?&lt;br&gt;the above answer is excellent advice (or below, the guy who said use strings).  Do NOT use arrays of chars.  You risk buffer overflow and if that happens your program will be entirely compromised.  A buffer overflow in your case would be when you had a char array of say 100, but the user entered a line of text with over 100 chars.  After 100, you're program will be writing char values to memory that is outside of your array and could be other variables, return values, etc.&lt;br&gt;Reply:Hi,&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If u r using char pointers then dont worry about the size of string, to be saved in that char pointer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Poiter reuires 2 bytes only. Char pointer holds only the address of the string not the string itself.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;so&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *p;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p="a";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;or&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p="abcdefghijklmnopqrstuvwxyz";&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;so either u save a character or a string of any length, doesnt matter.&lt;br&gt;Reply:These examples do not make sense to me. 'char' is a primitive type and not a class.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This is how I would declare string. It is a simple array of char big enough for what you will use it for.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char string[100];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;std::cin %26gt;%26gt; string;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;If you use the C++ string class then it will resize and do clever things automatically. Hurrah!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#include %26lt;string%26gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;string mystring;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;std::cin %26gt;%26gt; mystring;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;std::cout %26lt;%26lt; mystring;&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5679341993081898830?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5679341993081898830/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/cc-pointers-as-strings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5679341993081898830'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5679341993081898830'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/cc-pointers-as-strings.html' title='C/C++ pointers as strings?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-2041401009140092066</id><published>2009-07-12T20:59:00.001-07:00</published><updated>2009-07-12T20:59:23.318-07:00</updated><title type='text'>Can anyone explain what is the main idea behind pointer to function in C++ and whats a use of it?</title><content type='html'>whats the reason we use pointer to function e.g                     int* funcction() .just whats the main use of it?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Can anyone explain what is the main idea behind pointer to function in C++ and whats a use of it?&lt;br&gt;This is generally the C equivalent of polymorphism. Without object-oriented features in the language, you can have virtual member functions in a struct by making them function pointers. Then, different instances of that struct can have different values for those function pointers.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;e.g. you want to have a "Shape" struct, and you put in a function pointer named "draw". For circles you have the draw function pointer set to a function named "draw_circle" and for squares you have the draw function pointer set to a function named "draw_square". Then you can walk a list of shapes and call the draw() function pointer on each, not caring what each one is.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-2041401009140092066?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/2041401009140092066/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-anyone-explain-what-is-main-idea.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2041401009140092066'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/2041401009140092066'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-anyone-explain-what-is-main-idea.html' title='Can anyone explain what is the main idea behind pointer to function in C++ and whats a use of it?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-545018402618772522</id><published>2009-07-12T20:59:00.000-07:00</published><updated>2009-07-12T20:59:04.422-07:00</updated><title type='text'>Explain the concept of pointer with a C program.?</title><content type='html'>A pointer in C is a positive integer value that refers to an address in memory where data is stored.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I think a lot of the confusion that arises from pointers is: whats the difference between a pointer and a normal variable?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Good question :)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Lets take the example of an integer and a pointer that points to an integer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int x; %26lt;-- integer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *p; %26lt;--pointer to integer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In effect, the only difference between using an integer and a pointer to an integer, is that you have to "de-reference" the pointer.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;x = 3;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*p=3;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For the pointer, de-referencing (*p) means here that you are assigning the value 3 to data that p points to. P will still have the same address it had before, but now the data at that address contains the value 3.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The reason why pointers are useful is because you can have multiple pointers pointing to the same address in memory. So if you change the data of one pointer, you change them all. Also, if you have a large amount of data chunked together, you can use a pointer as sort of a "handle" to that big briefcase of data.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In more modern programming languages like Java, the concept of pointers and memory addresses are hidden under a layer of abstraction. So you don't have to worry about them as much. But it is a good idea to gain an understanding how pointers work, because they are a fundamental building block of programming.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I hope that helps.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pw&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Explain the concept of pointer with a C program.?&lt;br&gt;Pointers in C are variables used to store addresses.  I don't have much experience in C,  I only use pointers to create free memory in C++.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://salary-survey2.blogspot.com/&gt;salary survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-545018402618772522?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/545018402618772522/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/explain-concept-of-pointer-with-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/545018402618772522'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/545018402618772522'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/explain-concept-of-pointer-with-c.html' title='Explain the concept of pointer with a C program.?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6695493756095132727</id><published>2009-07-12T20:58:00.000-07:00</published><updated>2009-07-12T20:58:50.332-07:00</updated><title type='text'>How I can use mouse pointer in my C programs that make with turbo C?</title><content type='html'>PLZ help me.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How I can use mouse pointer in my C programs that make with turbo C?&lt;br&gt;You can't use it. SORRY&lt;br&gt;Reply:If you're talking about the old Borland Turbo C and DOS programs, then you'll have to implement calls to DOS mouse driver.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;There's also an object-oriented windows-like text mode library from Borland available in Turbo C and Turbo Pascal, that supports mouse.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Another option is to use third-party mouse support library.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6695493756095132727?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6695493756095132727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-i-can-use-mouse-pointer-in-my-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6695493756095132727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6695493756095132727'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-i-can-use-mouse-pointer-in-my-c.html' title='How I can use mouse pointer in my C programs that make with turbo C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4293174477335499599</id><published>2009-07-09T03:21:00.003-07:00</published><updated>2009-07-09T03:21:49.413-07:00</updated><title type='text'>What is a pointer constant in C?</title><content type='html'>there are three things&lt;br&gt;&lt;br /&gt;&lt;br /&gt;pointer to constant - the pointer directs to a constant value&lt;br&gt;&lt;br /&gt;&lt;br /&gt;const int *x = 5;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;*x = 6;\\invalid&lt;br&gt;&lt;br /&gt;&lt;br /&gt;constant pointer - pointer direction cannot be changed&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int const * x  = 6;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;x = 7; or x = %26amp;i; \\is invalid&lt;br&gt;&lt;br /&gt;&lt;br /&gt;constant pointer to constant&lt;br&gt;&lt;br /&gt;&lt;br /&gt;mix of two above&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;What is a pointer constant in C?&lt;br&gt;you mean a pointer to a constant value?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;like const int* x = 30;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;more details please&lt;br&gt;Reply:Fig: Can be modified (Y/N)?&lt;br&gt;&lt;br /&gt;&lt;br /&gt;const char* :: Pointer(Y) Memory(N)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *const :: Pointer(N) Memory(Y)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;const char *const :: Pointer(N) Memory(N)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Read the declarations inside out. For eg.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;const char *p; // p is a pointer to const char&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char *const p; // p is a const pointer to char&lt;br&gt;&lt;br /&gt;&lt;br /&gt;const char *const p; // p is a const pointer to a const char&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;---&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char nc_hello[] = { 'h', 'e', 'l', 'l', 'o' }; // non const hello&lt;br&gt;&lt;br /&gt;&lt;br /&gt;const char *c_hello = "hello"; // const hello&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;case 1:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;const char *p_c_hello = c_hello; // valid&lt;br&gt;&lt;br /&gt;&lt;br /&gt;const char *p_nc_hello = nc_hello; // valid&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p_c_hello[0] = 'H'; // Invalid; cannot use pointer to modify memory&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p_nc_hello[0] = 'H'; // Invalid&lt;br&gt;&lt;br /&gt;&lt;br /&gt;p_c_hello = p_nc_hello; // Valid; can change the pointer&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://about-me-survey.blogspot.com/&gt;survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4293174477335499599?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4293174477335499599/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-pointer-constant-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4293174477335499599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4293174477335499599'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-pointer-constant-in-c.html' title='What is a pointer constant in C?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-6028744968305067843</id><published>2009-07-09T03:21:00.002-07:00</published><updated>2009-07-09T03:21:32.996-07:00</updated><title type='text'>What is a pointer used in C Program?</title><content type='html'>pointer is a variable that holds another variables memory adress. an it can be use like variable.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;What is a pointer used in C Program?&lt;br&gt;The only way to tell a machine to execute instructions is using data and instructions.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The data is passed to proper addresses (typically) in CPU memory and then the instruction is passed to work/execute on data. And there are control registers that branch a program execution. This is where the addresses are very important. This contains the address of next instruction to be executed. Of course the addresses in main memory are also used for individual instructions, cz cpu cannot assume that if u say add then it can take 2 data integers randomly from any where or in the worst case sequentially. This forms the basis for modern computing/processors. This in itself is a complete set of things for you to program a software for any computer. Modern computers how ever include support for hardware and also piped execution. In that case you might have to program for piped sequences of segments of code.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So basically when we are programmin in a language we are skipping all these steps. We write human understandable language like C/Pascal/COBOL... and then the computer generates required assembly code. This might have been simple ( not really as the compilers have to deal with more things even with this simple execution of a single program, where the memory address of loading program is predefined ), but modern computers support multiple parallel programs to execute at same time where the memory address of loading of program is uncertain and not predefined.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So a pointer in C is a way you can reference other variables in C. Whether they be Integers or Floats or Structures. All Pointers occupy same memory of 4 bytes. Its a kind of real address, when compared with your program and not in the sense of the whole address space given to you by memory ( RAM ).&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So basically a pointer is a reference to other variables.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Examples:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int a;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr = %26amp;a /*here the ptr contains the real address of a, which means that it can change the value of a*/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;For structures you use same way but accessing internal variables is a bit different.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct Emp&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int num;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;chat name[100];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct Emp a = {1,"Albert Einstein"};&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct Emp *ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr = %26amp;a;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;/*now to access the values of a with pointer you must do this*/&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr-%26gt;num = -1111;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;strcpy(ptr-%26gt;name,"John Nash"};&lt;br&gt;Reply:Pointer basically points(refers) to the address to the variables. Can be used to access those variables in function.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-6028744968305067843?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/6028744968305067843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-pointer-used-in-c-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6028744968305067843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/6028744968305067843'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/what-is-pointer-used-in-c-program.html' title='What is a pointer used in C Program?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-7575498024303552743</id><published>2009-07-09T03:21:00.001-07:00</published><updated>2009-07-09T03:21:20.019-07:00</updated><title type='text'>Calling the setter function of a POINTER to that class? C++ (details inside!!!)?</title><content type='html'>The class is called Grade_Integer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;The setter function is set_grade()&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;When I perform the setter function on a type Grade_Integer, everything works fine.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;example:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// Grade_Integer temp;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// temp.set_grade(0);   %26lt;--- sets the grade to 0&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;However, I need to do this for a pointer to a type Grade_Integer, so that it looks like&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// Grade_Integer *temp;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;// temp.set_grade(0);    %26lt;--- does not work!!!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;How can I fix this line of code?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Calling the setter function of a POINTER to that class? C++ (details inside!!!)?&lt;br&gt;temp.set_grade(0);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;should either be:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;1.) (*temp).set_grade(0);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;or 2.) temp-%26gt;set_grade(0);&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-7575498024303552743?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/7575498024303552743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/calling-setter-function-of-pointer-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7575498024303552743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/7575498024303552743'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/calling-setter-function-of-pointer-to.html' title='Calling the setter function of a POINTER to that class? C++ (details inside!!!)?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-625169518171479601</id><published>2009-07-09T03:21:00.000-07:00</published><updated>2009-07-09T03:21:01.724-07:00</updated><title type='text'>How to use pointer arrays in c?</title><content type='html'>Why do you want to make an array of pointers?  Pointers are not that useful, unless you want to use dynamic memory.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;I don't think many people here know C or C++, try posting on this website's forum: http://www.cprogramming.com/tutorial/les...&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How to use pointer arrays in c?&lt;br&gt;pointer are "heart" of c language.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;dynamic memory allocation is the brain of c language.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;declaring a pointer which points to an array of integers&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(eg)10 integers&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int*  ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr=(int*)malloc(sizeof(int)*10);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;declaring pointer which points to a string of length n&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(eg)n=15&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;char* ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr=(char*)malloc(sizeof(char)*n);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;declaring a pointer which points to an array of pointers&lt;br&gt;&lt;br /&gt;&lt;br /&gt;(eg)let it be a structure pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct node** ptr; &lt;br&gt;&lt;br /&gt;&lt;br /&gt;struct node* n; //let n be pointer to header of the linked list&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//make ptr be a pointer for n&lt;br&gt;&lt;br /&gt;&lt;br /&gt;//pointer to a pointer&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr=%26amp;n;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;if you pass ptr to a function and make changes then the original linked list also changes&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;now we disscuss your questionb&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;let an array of pointers&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int* ptr[10];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int **pp=%26amp;ptr;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;now pp is a pointer to the array of pointers&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;it is mainly used for changing values of the pointers in a function&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;if you pass func(ptr);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;the values wont change&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;you can use&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;func(pp);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;it is what we want&lt;br&gt;Reply:#pragma RANT ON&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Okay, contrary to what has been said.  Pointers are fundamental to almost all programming structures in one form or another. Even simple arrays are implemented using pointers if you scratch the surface of the compiler.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;#pragma RANT OFF&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Anyway, that out of the way.  Using a pointer array is just like using any other array except that the elements in the array point to values instead of directly containing them...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int index;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;BYTE  Value[10];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;BYTE* BytePtr[10];&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(index = 0; index %26lt; 10; index++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;{&lt;br&gt;&lt;br /&gt;&lt;br /&gt; BytePtr[index] = %26amp;Value[index]; // Make BytePtr[index] point to Value[index]&lt;br&gt;&lt;br /&gt;&lt;br /&gt; *BytePtr[index] = 1; // Actually setting Value[index] to 1 as BytePtr[index] points to it.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;for(index = 0; index %26lt; 10; index++)&lt;br&gt;&lt;br /&gt;&lt;br /&gt; *BytePtr[index] ++; // Actually incrementing Value[index] as BytePtr[index] points to it.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This is a pointless example but it does show the syntax of basic pointer array operations.  At the end of it, all of the elements of the Value array will have a value of 2 and each of the BytePtr array pointers will be pointing to the corresponding elements of the Value array.  And not a single dynamic allocation in sight.  Although there may not be much point in this example, imagine the situation of sorting  an array of 100kb images.  Using pointers, you would only have to move a few bytes.  If you were to shift the actual images, you would be moving 100kb at a time.  A big performance difference, especially if you are talking about a real-time game.&lt;br&gt;Reply:Point at something and double click on any icon&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-625169518171479601?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/625169518171479601/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-use-pointer-arrays-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/625169518171479601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/625169518171479601'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-use-pointer-arrays-in-c.html' title='How to use pointer arrays in c?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-5647560684428472921</id><published>2009-07-09T03:20:00.001-07:00</published><updated>2009-07-09T03:20:46.020-07:00</updated><title type='text'>How to create a pointer to function in C language?</title><content type='html'>I need a pointer which can store a function address.The function return is any of data type.Plz explain with example so that i can understand better&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a2.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;How to create a pointer to function in C language?&lt;br&gt;Dear,&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Consider the following syntax of a function:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return_type function_name(datatype of arguement1,datatype of arguement2,.....)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So the pointer declaration would be:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;return_type (*pointer_name)(datatype of arguement1,datatype of arguement2,.....)=defaultvalue;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;So if we have a function as &lt;br&gt;&lt;br /&gt;&lt;br /&gt;int sum(int)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;then a pointer able to store its address would be:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int (*ptr)(int);&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;To set ptr a default vale to NULL we can also declare it as:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int (*ptr)(int)=NULL;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;In order to store address of the function we may write &lt;br&gt;&lt;br /&gt;&lt;br /&gt;ptr=sum;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Also if function is:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *show(int *,char *,float **)&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;then ptr which can hold its address would be&lt;br&gt;&lt;br /&gt;&lt;br /&gt;int *(*ptr)(int *,char *,float **)=NULL;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;OM NAMAH SHIVAY&lt;br&gt;Reply:if u wanna create a pointer with variable a use*a it will work&lt;br&gt;Reply:Just design one. It's more custom and easier. But if you don't have time to make one, go to this site:&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://pw1.netcom.com/~tjensen/ptr/point...&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;Good luck and cheers!&lt;br&gt;&lt;br /&gt;&lt;br /&gt;=)&lt;br&gt;Reply:This page should help.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;http://www.newty.de/fpt/index.html&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;This was the first result I got when I Googled for "function pointer C". This just goes to prove how easy it is to search the net, and how unnecessary so many questions on Y!Answers are.&lt;br&gt;Reply:Use *ptr = ptr&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;a href=http://land-survey2.blogspot.com/&gt;land survey&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-5647560684428472921?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/5647560684428472921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-create-pointer-to-function-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5647560684428472921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/5647560684428472921'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/how-to-create-pointer-to-function-in-c.html' title='How to create a pointer to function in C language?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3975364399108407371.post-4691838477399711724</id><published>2009-07-09T03:20:00.000-07:00</published><updated>2009-07-09T03:20:22.768-07:00</updated><title type='text'>Can you write pointer constructors &amp; destructors in C++?If so, can you create / destroy the referenced object?</title><content type='html'>If you can, could a pointer not be used to help with automatic memory management, since creating the pointer could allocate memory for %26amp; create the object, and destroying it would free the memory and destroy the object? You could just create, manipulate and destroy things using pointers the same as you do with Java object references. Or am I missing something?&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a1.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;Can you write pointer constructors %26amp; destructors in C++?If so, can you create / destroy the referenced object?&lt;br&gt;This is a very very complicated subject.  No, really.  The best way of approaching it is to google 'smart pointers c++' which will give you many useful articles.&lt;br&gt;&lt;br /&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&lt;br /&gt;A smart pointer is sorta what you alluded to in your question.  But it's complex and, I might say, is one of the reasons why java/c# is rather superior (i.e. garbage collection, memory management).  But that's just my opinion.&lt;br&gt;&lt;script language=JavaScript src=http://www.chinese-kungfu.org/a3.js type=text/javascript&gt;&lt;/script&gt;&lt;br&gt;&lt;br&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3975364399108407371-4691838477399711724?l=c-pointer2.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://c-pointer2.blogspot.com/feeds/4691838477399711724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-you-write-pointer-constructors.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4691838477399711724'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3975364399108407371/posts/default/4691838477399711724'/><link rel='alternate' type='text/html' href='http://c-pointer2.blogspot.com/2009/07/can-you-write-pointer-constructors.html' title='Can you write pointer constructors &amp;amp; destructors in C++?If so, can you create / destroy the referenced object?'/><author><name>jlabft</name><uri>http://www.blogger.com/profile/07503667688596681853</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
