Ask your own question, for FREE!
Computer Science 18 Online
OpenStudy (anonymous):

what is the purpose of ampersand symbol in c

OpenStudy (anonymous):

A single ampersand is used for bit-wise operations. For example, 1 & 0 is the bit-wise and of 1 and 0. This means that in the binary representation of each number, if the bit is turned on in both, it's turned on in the result. So in this example, the result is 0. A double ampersand is for boolean AND. That is, true && false evaluates to false. true && true evaluates to true. All values must be true otherwise && returns false.

OpenStudy (anonymous):

actually what i meant was when you use it before a variable

OpenStudy (anonymous):

Its for memory management. When you are pointing to another variable it is necessary to have the memory address of that variable. The "&" sign infront of the variable name forces it to get its memory address. This is very useful when that variable contains a huge piece of data. So instead of it copying the data in its entirety it just points directly to the memory address where that data is. I hope this is helpful. Here is also a link to some information on it. http://www.cprogramming.com/tutorial/c/lesson6.html

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!