The best solution is to just compile your code with a C compiler, as this is C code. You really shouldn't compile C code as if it were C++. However, to directly answer your question, you can force the C++ compiler to compile your C code (which is very bad!!!!).
In C++, whenever you use any function of the alloc
family, you must cast the return value to the type of your lvalue. So, in this case:
Teclas = (char*)calloc(1024, sizeof(char));
The way in which I would do the above is like this:
Teclas = (char*)malloc(1024 * sizeof(*Teclas));
The benefits here: If you change the type of Teclas
, you will still end up with the correct allocation size. Also, I just prefer using malloc
in general.
Additionally, you have major issues throughout your code. For one thing, void int main(...)
???? And you never initialize the contents of Teclas
before you print it, but you free it and calloc it again for some reason. I think you meant to make that a do while loop, but there is no do
.
Also, void KeyLogger();
is WRONG. That is how you declare the function, but since it is a declaration, it should be outside of main.