Pointer to int. C++
16,813
Solution 1
You can just pass &b to the function; no need for an intermediate pointer variable.
Solution 2
Why to create a pointer variable?. Why can't you do it like this?.
int b = 5;
func(&b)
Solution 3
void f(int *i)
{
//...
}
int b = 5;
f(&b);
is enough!
Author by
Hooch
Updated on June 19, 2022Comments
-
Hooch almost 2 years
I need to pass to function pointer to int. Now if I want to pass 5 I'm doing it like this:
int * i = NULL; int b = 5; i = &b;
Is there any better way to write it shorter?
I want to pass bytes that are in i int to this function:
void Write2Asm(void* pxAddress, BYTE * MyBytes, int size)