Salut,
Je suis en train de lire le livre "Thinking in c++ 2nd, Vol. 1" et j'ai de la difficult� � comprendre un exercice. Voici l'�nonc�, �a explique tout:
Je ne comprend pas exactement ce qu'ils veulent que je fasse. Enfin, j'en suis arriv� � ceci pour le moment: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.
Je ne sais m�me pas si je suis dans le bonne direction... �a doit �tre d� � ma compr�hension de l'anglais
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include <iostream> using namespace std; void unefonction( void* pletableau, int nboctets, int valeur); int main() { int montableau[10]; int* p = montableau; void* pv = static_cast<void*>(p); unefonction( pv, sizeof(int), 10); } void unefonction( void* pletableau, int nboctets, int valeur) { // Aucune idée quoi faire ici. }
Quelqu'un peut me dire si je suis dans la bonne direction ou me dire ce que vous pensez qu'ils veulent que je fasse dans la fonction.
Merci.







R�pondre avec citation








Partager