C
Charles
I am going through the exercises and Bruce Eckel's Thinking in C++ and
I ran into an exercise that wasn't included in his solutions that I
think I could use some assistance with.
Exercise 3-26 pg 213:
Define an array of int. Take the starting address of that array and
use static_cast to convert it into an void*. Write a function that
takes a void*, a number (indicating a number of bytes), and a value
(indicating the value to which each byte should be set) as arguments.
The function should set each byte in the specified range to the
specified value. Try out the function on your array of int.
Here is what I have so far: (which isnt much)
#include <iostream>
using namespace std;
void fn (void* v, int n)
{
}
int main ()
{
int a[10];
void* vp = static_cast<void*>(&a);
return 0;
}
Maybe somebody can help me translate what is being asked in the
exercise.
Thanks in advance for any tips,
Charles
I ran into an exercise that wasn't included in his solutions that I
think I could use some assistance with.
Exercise 3-26 pg 213:
Define an array of int. Take the starting address of that array and
use static_cast to convert it into an void*. Write a function that
takes a void*, a number (indicating a number of bytes), and a value
(indicating the value to which each byte should be set) as arguments.
The function should set each byte in the specified range to the
specified value. Try out the function on your array of int.
Here is what I have so far: (which isnt much)
#include <iostream>
using namespace std;
void fn (void* v, int n)
{
}
int main ()
{
int a[10];
void* vp = static_cast<void*>(&a);
return 0;
}
Maybe somebody can help me translate what is being asked in the
exercise.
Thanks in advance for any tips,
Charles