Diese Präsentation wurde erfolgreich gemeldet.

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige

1 von 2 Anzeige

# Write a function called HugeInteger -hugeDestroyer(HugeInteger -p)- De.docx

Write a function called HugeInteger *hugeDestroyer(HugeInteger *p);
Description: Destroy any and all dynamically allocated memory associated with p. Avoid segmentation faults and memory leaks.
Returns: NULL
There is also this to use:
typedef struct HugeInteger
{
// a dynamically allocated array to hold the digits of a huge integer
int *digits;
// the number of digits in the huge integer (approx. equal to array length)
int length;
} HugeInteger;
Solution
#include<iostream>
using namespace std;
typedef struct HugeInteger
{
// a dynamically allocated array to hold the digits of a huge integer
int *digits;
// the number of digits in the huge integer (approx. equal to array length)
int length;
} HugeInteger;
HugeInteger *hugeDestroyer(HugeInteger *p){
delete []p;
return NULL;
}
int main(){
HugeInteger *p = new HugeInteger[10];
if(hugeDestroyer(p) == NULL)
cout<<\"All memory is deallocated\";
return 0;
}
.

Write a function called HugeInteger *hugeDestroyer(HugeInteger *p);
Description: Destroy any and all dynamically allocated memory associated with p. Avoid segmentation faults and memory leaks.
Returns: NULL
There is also this to use:
typedef struct HugeInteger
{
// a dynamically allocated array to hold the digits of a huge integer
int *digits;
// the number of digits in the huge integer (approx. equal to array length)
int length;
} HugeInteger;
Solution
#include<iostream>
using namespace std;
typedef struct HugeInteger
{
// a dynamically allocated array to hold the digits of a huge integer
int *digits;
// the number of digits in the huge integer (approx. equal to array length)
int length;
} HugeInteger;
HugeInteger *hugeDestroyer(HugeInteger *p){
delete []p;
return NULL;
}
int main(){
HugeInteger *p = new HugeInteger[10];
if(hugeDestroyer(p) == NULL)
cout<<\"All memory is deallocated\";
return 0;
}
.

Anzeige
Anzeige

## Weitere Verwandte Inhalte

Anzeige

### Write a function called HugeInteger -hugeDestroyer(HugeInteger -p)- De.docx

1. 1. Write a function called HugeInteger *hugeDestroyer(HugeInteger *p); Description: Destroy any and all dynamically allocated memory associated with p. Avoid segmentation faults and memory leaks. Returns: NULL There is also this to use: typedef struct HugeInteger { // a dynamically allocated array to hold the digits of a huge integer int *digits; // the number of digits in the huge integer (approx. equal to array length) int length; } HugeInteger; Solution #include<iostream> using namespace std; typedef struct HugeInteger { // a dynamically allocated array to hold the digits of a huge integer int *digits; // the number of digits in the huge integer (approx. equal to array length) int length; } HugeInteger; HugeInteger *hugeDestroyer(HugeInteger *p){ delete []p;
2. 2. return NULL; } int main(){ HugeInteger *p = new HugeInteger[10]; if(hugeDestroyer(p) == NULL) cout<<"All memory is deallocated"; return 0; }