Thread: Heap Work

  1. #1
    Fallen AndyBomstad's Avatar
    Join Date
    Jan 2005

    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
    //Written By : Andrew Bomstad
    // "Heap Work"
    #define cls system("cls")
    #define pause system("pause")
    using namespace std;
    char heap(char *p);
    int main()
        char input[10];
        char h = heap(input);
        return 0;
    char heap(char *p)
         char *h = new char [p,len(p + 1)];
         return h;     
    any help on this would be great!

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    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.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Heap corruption detected. What does it mean?
    By franziss in forum C++ Programming
    Replies: 17
    Last Post: 07-23-2008, 02:50 AM
  2. Heap Program Help
    By Rob4226 in forum C++ Programming
    Replies: 15
    Last Post: 05-02-2008, 01:23 AM
  3. heap
    By George2 in forum Windows Programming
    Replies: 2
    Last Post: 11-10-2007, 11:49 PM
  4. Suggestions on this C style code
    By Joelito in forum C Programming
    Replies: 11
    Last Post: 06-07-2007, 03:22 AM
  5. Cygwin GCC setting for heap
    By stlait00 in forum C Programming
    Replies: 1
    Last Post: 05-02-2006, 05:32 AM