-
Heap Work
Ok so what im trying to do now is learn how to use the "Heap",
(if anyone has a tutorial for this that would be great)
so in this program im getting input from the user and sending it into char input[10]; using cin.getline
i then want to send that input into a function that will then Create a "Heap" space that is the size of the input
then put the input onto the heap and have the function return the "heap input" into main and then display the message
this program is very flawed obviously
Code:
//Written By : Andrew Bomstad
// "Heap Work"
#include<iostream>
#define cls system("cls")
#define pause system("pause")
using namespace std;
char heap(char *p);
int main()
{
char input[10];
cin.getline(input,sizeof(input));
char h = heap(input);
cout<<h<<endl;
pause;
return 0;
}
char heap(char *p)
{
char *h = new char [p,len(p + 1)];
return h;
}
any help on this would be great!
-
dont try and work with the heap until you understand pointers better. Try looking through the tuts available on this site for pointers then look at the dynamic allocation tuts.