Pointers in C and C++

Posted by Tushar Bedekar
The correct understanding and use of pointers is crucial to successful C programming. There are several reasons for this: First, pointers provide the means by which functions can modify their calling arguments. Second, pointers support dynamic allocation. Third, pointers can improve the efficiency of certain routines. Finally, pointers provide support for dynamic data structures, such as binary trees and linked lists.
Pointers are one of the strongest but also one of the most dangerous features in C. For example, a pointer containing an invalid value can cause your program to crash. Perhaps worse, it is easy to use pointers incorrectly, causing bugs that are very difficult to find. Because of their importance and their potential for abuse, this chapter examines the subject of pointers in detail.

What Are Pointers?

A pointer is a variable that holds a memory address. This address is the location of another object (typically another variable) in memory. For example, if one variable contains the address of another variable, the first variable is said to point to the second. 


Pointer Variables

If a variable is going to be a pointer, it must be declared as such. A pointer declaration consists of a base type, an *, and the variable name. The general form for declaring a pointer variable is
type *name;
where type is the base type of the pointer and may be any valid type. The name of the pointer variable is specified by name.
The base type of the pointer defines the type of object to which the pointer will point. Technically, any type of pointer can point anywhere in memory. However, all pointer operations are done relative to the pointer's base type. For example, when you declare a pointer to be of type int *, the compiler assumes that any address that it holds points to an integer— whether it actually does or not. (That is, an int * pointer always ''thinks" that it points to an int object, no matter what that piece of memory actually contains.) Therefore, when you declare a pointer, you must make sure that its type is compatible with the type of object to which you want to point.

The Pointer Operators

There are two pointer operators: * and &. The & is a unary operator that returns the memory address of its operand. (Remember, a unary operator only requires one operand.) For example,
m = &count;
places into m the memory address of the variable count. This address is the computer's internal location of the variable. It has nothing to do with the value of count. You can think of & as returning "the address of." Therefore, the preceding assignment statement can be verbalized as "m receives the address of count."
Image result for pointer in cTo understand the above assignment better, assume that the variable count uses memory location 2000 to store its value. Also assume that count has a value of 100. Then, after the preceding assignment, m will have the value 2000.
The second pointer operator, *, is the complement of &. It is a unary operator that returns the value located at the address that follows. For example, if m contains the memory address of the variable count,
q = *m;
places the value of count into q. Thus, q will have the value 100 because 100 is stored at location 2000, which is the memory address that was stored in m. You can think of * as "at address." In this case, the preceding statement can be verbalized as "q receives the value at address m."

note:-These are the basic things that we have discussed today for more articles on pointer stay connected with us.

For any kind of doubts feel free to ask on contact us
     
Read More

How to get best Android phone for today: 5 models

Posted by Tushar Bedekar
These days everyone seems to want the latest smart phone to come out, but who can blame them when you look at how rapidly these devices are improving. Technology truly has ramped up the speed at which we consume new products, although that simply means that consumers have more access to better quality materials. Although Apple continues to dominate the smart phone market, there is no question that Android is highly popular and a good percentage of the population would not even consider purchasing a new phone. If you want to get your hands on the latest Android phone's, a good place to start is by doing some research on the internet and checking out the various models that they currently have available. 
Although you might want to go into the store to make your actual purchase, more and more people are preferring to pick up their new smart phones over the internet. This is due in large part to the fact that you can generally get much better deals over the internet, because the online retailers have to compete with all sorts of sites, where as if you were to walk into a store, they do not have much competition. For this reason alone, you should see if you can find a better price online, although it is a good idea to head to the stores to actually get the phones you are looking at in your hand, so you get a feel of whether you like them or not. However, if you are a die hard Android fan, this may not pertain to you, as you likely are going to purchase their products anyway. 
If you are looking into getting a brand new Android phone, you may want to consider some of these models. The Samsung Galaxy Note 5 has gotten great reviews online and is far superior than the previous models that Samsung has put out in the past, which were lacking in a great deal of areas. They Galaxy Note 5 features a top of the line display screen, which has gotten the phone a lot of attention. The overall features in the phone, in regards to multitasking, taking pictures and videos, and maintaining a long battery life, are drastically better than previous Samsung models. 
The LG G4 is one of the highest rated Androids on the market right now and they have been called a great all around smart phone. The display screen is crisp and the camera takes high quality shots consistently and there is no question that the software is drastically improving as well. Samsung has another great Android model out, which is the Galaxy S6. This phone has had some reviews that are calling it hands down the best phone on the market, including the iPhone, which got a ton of people's attention. There is no doubt that this is a high quality phone worth considering and at about three hundred dollars less than the Galaxy Note 5, it may be an overall better purchase.
If you are looking for a bit of a cheaper phone that still has a ton of the same capabilities and looks great, you might want to check out the Moto X. Although this phone is less popular and has gotten lower reviews, the camera is of the utmost quality, the software on the phone is great and it holds a long battery life. The Sony Xperia Z5 Premium is another great phone that will also likely get you a lot of looks. This is due to the fact that they sell a bright gold smart phone, which looks amazing and is on par function wise as the top Androids on the market.

About Author: This article was written by Andy G, a tech geek and Linux guru from Austria. At the present moment he maintains firmware 

and driver download website called http://www.helpjet.net/
Read More
back to top