answersLogoWhite

0

If the pointer is pointing to an array, you would do the exact same and use [], but if it weren't pointing to an array, you can use * to extract data from the pointer.

eg:

int a = 5; //set a to 5

int* b = &a;//set b to the address pointed by b

int result = *b; //extract data b is pointing to (5)

result would then be 5

User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering

What is the purpose of using arrays in C language?

The purpose of using arrays in C is to store multiple values in one variable. Then you can make programs that use arrays like lists, printing values from multiple arrays into one line. It take memory in continues block then we can know memory location easily. We can retrieve data quickly.


How do you write a program in c plus plus to swap each half of an array?

Swapping array elements is simple enough. The only issue is what to do with the middle element when there are an odd number of elements. The following program simply leaves it where it is. #include<iostream> #include<vector> template<typename T> void exchange (std::vector<T>& v) { if (v.size()<2) return; size_t left = 0; size_t right = v.size() / 2; if (v.size()%2) ++right; // skip middle element while (right < v.size()) std::swap (v[left++], v[right++]); } int main() { std::vector<unsigned> v {4, 8, 15, 16, 23, 42, 69}; for (auto n : v) std::cout << n << ' '; std::cout << std::endl; exchange (v); for (auto n : v) std::cout << n << ' '; std::cout << std::endl; }


What is difference between Deep copy and shallow copy?

A "shallow" copy is when the member values are physically copied from one object to another, *including* the values of any pointer or reference members. If there are pointer or reference memebrs, then, those poointers or references refer to the *same* objects as the original object, which is usually a bad thing. That's why you want to define a copy constructor and assignment operator for objects that contain pointers or references. It's called a "shallow" copy because only the values of the pointers/references are copied, instead of making copies of those referred-to objects and setting pointers to them. *That* is what would be called a "deep" copy, because it's going "deeper" into the structure, copying everything, not just the first "layer".


What are the operations that can be performed using a pointer expression?

a. adding and subtracting the integer values b. adding and subtracting the pointers c. incrementing and decrementing the pointers other than tis pointer operations include relational operations such as =,<,>.


What are the advantages of a pointer variable?

Arrays takes consecutive memory space. So, if you have 5 consecutive memory blocks free which is consecutive, an error will occur while creating an array which takes more than 5 blocks of memory. But if you use pointer, then it don't need consecutive memory blocks all the elements can be placed anywhere in memory.

Related Questions

Are numpy arrays mutable, meaning can their values be changed after they are created?

Yes, numpy arrays are mutable, which means that their values can be changed after they are created.


What is the purpose of using arrays in C language?

The purpose of using arrays in C is to store multiple values in one variable. Then you can make programs that use arrays like lists, printing values from multiple arrays into one line. It take memory in continues block then we can know memory location easily. We can retrieve data quickly.


How do you get difference between two or more arrays in PHP?

The inherit function `array_dif($arrayOne, $arrayTwo, $arrayThree, ...)` is likely what you're looking for. It compares two or more arrays, and returns an array of values that are unique among the arrays.


How does one use JavaScript arrays?

JavaScript arrays is used to generalize multiple values of data and store them in a single variable. This is a useful software in most programming languages.


How do you write a program in c plus plus to swap each half of an array?

Swapping array elements is simple enough. The only issue is what to do with the middle element when there are an odd number of elements. The following program simply leaves it where it is. #include<iostream> #include<vector> template<typename T> void exchange (std::vector<T>& v) { if (v.size()<2) return; size_t left = 0; size_t right = v.size() / 2; if (v.size()%2) ++right; // skip middle element while (right < v.size()) std::swap (v[left++], v[right++]); } int main() { std::vector<unsigned> v {4, 8, 15, 16, 23, 42, 69}; for (auto n : v) std::cout << n << ' '; std::cout << std::endl; exchange (v); for (auto n : v) std::cout << n << ' '; std::cout << std::endl; }


What is the purpose of initialising an array?

Arrays are variables, so your question is: What is the purpose of initialising a variable? Answer: assigning initial values to them.


What are 7 ways to do 12 arrays?

To create 12 arrays using 7 different methods, you can consider various strategies such as: Combination: Use combinations of elements to form arrays. Permutations: Rearrange a set of elements to create distinct arrays. Subsets: Generate subsets from a larger set to form smaller arrays. Cartesian Products: Combine multiple sets to produce arrays. Recursive Generation: Utilize a recursive algorithm to build arrays systematically. Random Sampling: Randomly select elements to generate different arrays. Dynamic Programming: Apply dynamic programming techniques to build arrays based on previously computed values. These methods can be employed in various contexts, depending on the desired properties of the arrays.


What is the median of two arrays when combined into a single array?

To find the median of two arrays when combined into a single array, first merge the arrays and then calculate the median by finding the middle value if the total number of elements is odd, or by averaging the two middle values if the total number of elements is even.


What is an Object that represents the individual values?

An array or a dictionary is commonly used as an object to represent individual values. Arrays are used when the values are ordered and accessed by index, while dictionaries are used when the values are stored with corresponding keys for easy lookup.


Is array list value type or reference type?

Arrays are reference type. array values are always pass by reference.


What is scalar values?

Scalar values are single values, not arrays or objects, representing a single data point such as a number, string, or boolean. In programming, scalar values are not composite data structures and do not contain nested values. Examples of scalar values include integers, floating-point numbers, and characters.


What is the technique used for adding and subtracting values from the pointers address in order to access other memory locations called?

WikiAnswers does not provide information about illegal acts, such as cracking other computers through pointer manipulation.