Author Topic: How to convert C++ operator to C?  (Read 452 times)

Offline bitcoin

  • Member
  • *
  • Posts: 108
How to convert C++ operator to C?
« on: April 17, 2020, 12:04:39 pm »
I have trouble with C++ operator &

How to convert code to C. Such as:

Code: [Select]
DetourDetach(&(PVOID&)TrueMessageBoxA, MyMessageBoxA);
This don't compile with C and don't work without ampserdants. (lib is Microsoft Detours)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 1788
Re: How to convert C++ operator to C?
« Reply #1 on: April 17, 2020, 03:39:22 pm »
This case ampersand in C++ means a reference to a variable. In C it behaves like a pointer.
But be careful: a reference is not a pointer in C++ (don't say something like that on stackoverflow or you'll get strongly and continuosly downvoted  ;D ;D ;D ;D ;D People don't read the contest just outline the first thing seemingly strange at them  ;D ;D ;D ;D)
The code is to be translated as:
Code: [Select]
DetourDetach(&TrueMessageBoxA, MyMessageBoxA);
« Last Edit: April 17, 2020, 03:48:25 pm by frankie »