Aug 19, 2018 04:30 PM
(This post was last modified: Aug 19, 2018 05:15 PM by aeiro.)
As you all may have noticed i'm trying to expand my knowledge of pointers.
Right now i'm working with void* and am using a macro defined as #define Make(x, y, z) (*((x*)(y)+z))
I've got a function that sets all the values in a struct to 0. works fine until i attempt this with a void*.
I understand that Make(char, prTest, i*TypeSize) = NULL; will input 1 Byte into the address of prTest + i*TypeSize. I want to somehow fill Sizeof(Byte)*TypeSize
EDIT**
changed function to write everybyte
Right now i'm working with void* and am using a macro defined as #define Make(x, y, z) (*((x*)(y)+z))
I've got a function that sets all the values in a struct to 0. works fine until i attempt this with a void*.
PHP Code
<?php
void Instant(int size, void* &prTest, int TypeSize) //TypeSize = sizeof(int) atm
{
for (int i = 0; i < size; i++)
{
Make(char, prTest, i*TypeSize) = NULL; /////////Is there anyway i can cast this by the size of the type?
//instead of creating a switch statement determining the value of type size and incrementing through the pointer by that type?
/*
switch (TypeSize)
{
case sizeof(int) :
Make(int, prTest, i) = NULL;
}
*/
}
}
I understand that Make(char, prTest, i*TypeSize) = NULL; will input 1 Byte into the address of prTest + i*TypeSize. I want to somehow fill Sizeof(Byte)*TypeSize
EDIT**
changed function to write everybyte
PHP Code
<?php
void Instant(int size, void* &prTest, int TypeSize) //TypeSize = sizeof(Struct)
{
for (int i = 0; i < size * TypeSize; i++)
(Make(char, prTest, i)) = NULL;
}


![[Image: 5Iq5rDJ.gif]](https://i.imgur.com/5Iq5rDJ.gif)