Vote count:
0
So I need to create a call to strange_step that results in it printing out the if statement:
void strange_step(void* value)
{
if(*(int*)(value+5) == 15)
printf("4: Illinois\n");
else
printf("4: ERROR\n");
}
I've tried the following (since to my knowledge, with gcc, it treats void* like a char* so increments 1 byte):
int arr[10];
arr[4] = 15;
arr[5] = 15;
arr[3] = 15;
arr[2] = 15;
arr[6] = 15;
arr[7] = 15;
arr[8] = 15;
arr[9] = 15;
//arr[10] = 15;
strange_step(arr);
But that just seems to print out random numbers. What am I missing?
asked 31 secs ago
Arithmetic pointer with void*
Aucun commentaire:
Enregistrer un commentaire