M
Mark Antony
Hello everyone,
I am writing a function that takes a void* as an argument. In this
function, there is some data that needs to be given back in the form
of a void pointer. This is the simple test that I am trying to do:
////////////////////////CODE/////////////////////////////////
#include <stdio.h>
long f(int i, void *b){
float*fp;
char* a = "Hello";
float*tp = (float *)a;
printf("tp = %p\tb = %p\n", tp, b);
b = tp;
printf("tp = %p\tb = %p\n", tp, b);
return 0;
}
int main() {
void* pb;
printf("pb = %p\n", pb);
f(2, pb);
printf("pb = %p\n", pb);
return 0;
}
///////////////////////////END CODE///////////////////////
///////////////////////////OUTPUT//////////////////////////
pb = CCCCCCCC
tp = 00422030 b = CCCCCCCC
tp = 00422030 b = 00422030
pb = CCCCCCCC
///////////////////////////END OUTPUT//////////////////////
But what I want is that inside the function that I call, the void
pointer should be redirected, i.e. pb should be equal to 00422030, pb
= b.
(I know the above code is weird but I want to illustrate the fact that
I am trying to make the void* point to another place).
I think that this should be possible and the void pointer should point
to the address that I want to in the function.
But this is not happenning. Please help.
Thanks for everyone who replies.
With best regards,
Mark Antony
I am writing a function that takes a void* as an argument. In this
function, there is some data that needs to be given back in the form
of a void pointer. This is the simple test that I am trying to do:
////////////////////////CODE/////////////////////////////////
#include <stdio.h>
long f(int i, void *b){
float*fp;
char* a = "Hello";
float*tp = (float *)a;
printf("tp = %p\tb = %p\n", tp, b);
b = tp;
printf("tp = %p\tb = %p\n", tp, b);
return 0;
}
int main() {
void* pb;
printf("pb = %p\n", pb);
f(2, pb);
printf("pb = %p\n", pb);
return 0;
}
///////////////////////////END CODE///////////////////////
///////////////////////////OUTPUT//////////////////////////
pb = CCCCCCCC
tp = 00422030 b = CCCCCCCC
tp = 00422030 b = 00422030
pb = CCCCCCCC
///////////////////////////END OUTPUT//////////////////////
But what I want is that inside the function that I call, the void
pointer should be redirected, i.e. pb should be equal to 00422030, pb
= b.
(I know the above code is weird but I want to illustrate the fact that
I am trying to make the void* point to another place).
I think that this should be possible and the void pointer should point
to the address that I want to in the function.
But this is not happenning. Please help.
Thanks for everyone who replies.
With best regards,
Mark Antony