Some question about pointer in c - Page 1
Forum section: electronics / beginners

author: khatus
author_rank: Regular Contributor
timestamp: May 19, 2020, 04:15:11 pm
content: Hello guys i have some question regarding C pointer.Here What is meant by mixed call here?Having trouble understanding the meaning of the red lines? Can anyone explain?

author: greenpossum
author_rank: Frequent Contributor
timestamp: May 19, 2020, 04:23:52 pm
content: Mixed call is not standard terminology. It seems to have been invented by the author. In a sense there is nothing mixed, in C all arguments to functions are passed by value. So in order to be able to modify the actual variable rather than just a copy of the value you need to pass the address of the variable so that the callee can modify the original variable.

author: chriva
author_rank: Regular Contributor
timestamp: May 19, 2020, 04:47:35 pm
content: Forget "mixed call" it's just something they made up to point out the difference from other examplesTo break it down slightly:areaperi ( int r, float *a, float *p )Let's start with r.r is passed as regular data so the function is only aware of what the value is. Not where it's stored in the program. (ie. I called you on the phone and told you a number, I'm deaf so you can't tell me the answer)a and p are both pointers.These are passed as an address. (ie. I called you on the phone and told you where my mailbox is located. Remember I'm deaf so I can't hear you. You can do whatever you want to it and and I'll come back later and check what you've done)Difference is that I can't know what you've done to that number after the call. I can, however, check what you stored in my mailbox

author: Mechatrommer
author_rank: Super Contributor
timestamp: May 19, 2020, 05:20:51 pm
content: its clearly explained in the text about the author's term... "in the sense radius.. (is passed by value) and area and perimeter.. (are passed by reference).. passed by value means, technically speaking, the callee function will make another copy of the passed variable locally so any modification will only be made to that copy, not the original variable (from caller function). passed by reference (pointer), the callee function will directly modify the variable passed from the caller function.

author: helius
author_rank: Super Contributor
timestamp: May 19, 2020, 07:34:02 pm
content: In some languages, like Ada, procedures (functions) can have "IN", "OUT", or "INOUT" parameters. In anormal functionwith only "IN" parameters, the only output of the function is its result orreturn value, the object that replaces the function call when it's used in an expression. If there are "OUT" parameters, the procedure canstorevaluesintothem asadditional outputs. An "INOUT" parameter passes a value into the procedure and can also receive one of the procedure's outputs.C and C++ do not have formal syntax for "OUT", or "INOUT", but achieve the same effect usingpointerandreference arguments. By storing through a pointer given as an argument, a C function canoutputinto the object addressed by the pointer. By assigning to a reference argument, a C++ function canoutputto the object passed as the argument. These "functions with additional outputs" are not functions in the math sense, since they are not necessarily idempotent.