Hello,
I am using VC++ and I am testing some C code. I am tying to pass a void pointer !!! I was wondering if someone can help me with the following code sample. I get an "unhandled exception" error at the following line:
P->a = 9;
Here is the full sample code:
Code:
#include <stdio.h>
typedef struct tag1{
int a;
}t1;
typedef struct tag2{
int b;
}t2;
void f1(void *i)
{
t1 *P;
P = (t1*)i; // <<< Type cast!
P->a = 9; // <<< error here???
}
int main()
{
int x;
t1 *p = NULL;
t2 *q = NULL;
f1(p);
x = p->a;
}
Thankyou all in advance for your help!