answersLogoWhite

0

What is deference operator in c?

Updated: 10/25/2022
User Avatar

Wiki User

11y ago

Best Answer

There is no deference operator in C or C++.

However, the language supports references, and supports accessing values through pointers. The latter is sometimes called dereferencing.

Consider P to be a pointer to V. The asterisk is used to dereference V through P, that is, to access V: *P = 5 assigns value 5 to V (again, provided P points to V).

Note that the asterisk has different meanings in the C language, depending on the context in which it is used.

Now consider P to be a pointer to a structure S with members S.A and S.B. The right arrow operator can be used to dereference members S.A and S.B through P: P->A = 5; P->B = 13; assigns 5 and 13 to S.A and S.B, respectively.

The C++ language also knows a construct called references, which supports passing of arguments by reference rather than by value, without the complication and risk of pointer operations.

To declare a function argument as a reference, use the ampersand:

void example(int& v) {

v *= 2;

}

int i = 3;

void test(void) {

example(i);

}

After calling the test() function, variable i has value 6. Notice how no "referencing" operator was required in the all to the example function, and notice how the example function used the ampersand in the prototype declaration, but did not require a dedicated dereferencing operator when modifying the argument v.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is deference operator in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the basic operator in turbo c?

+ += - -= * *= / /= % %= = == != <= >= & && | ^ ~ << <<= >> >>= , [] () are the basic operator in TURBO C


What is the operator that cannot be overloaded in c plus plus and java?

conditional operator , size of operator , membership operator and scope resulation operator can not be overload in c++


Use of scope resolution operator in C programming?

:: operator can not be used in C.


What is the memory management operator in c plus plus?

There is no memory management operator in C++ -- it is an unmanaged language. You use the C++ new operator to allocate memory, and use the C++ delete operator to release previously allocated memory.


Is it possible to do operator overloading in c?

No. Operator and/or function overloading is only a C++ thing.


What is condional operator?

Conditional Operator- Its the only ternary operator in c/c++.- Its syntax is-(condition)?statement1:statement2;-Shruti Jain


C coding for operator overloading?

C does not support operator overloading. If you mean C++ operator overloading, it depends on exactly what you wanted to do. If you wanted to '+' to strings, then you could write: string operator+(string a, string b) { // do something }


Which is dummy operator in c?

In C, the sizeof operator can be considered a dummy operator because it does not perform any operations on the data but simply returns the size in bytes of a variable or a data type.


What is THIS operator in c?

The this operator is not a c operator. It is a c++ keyword. It is equivalent to an r-value pointer to the current instance of an object. It is useful when resolving between object members and method parameters.


Example of binaray operator in c plus plus?

+ is an example, one of many, of a binary operator in C or C++ a = b + c; // for usage example


What is the operator of power in c plus plus?

There is no "power" operator in C or C++. You need to the use the math library function pow().


What do you have to major in to become a C and C operator?

C and C operation