Heap Work

This is a discussion on Heap Work within the C++ Programming forums, part of the General Programming Boards category; Ok so what im trying to do now is learn how to use the "Heap", (if anyone has a tutorial ...

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

    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!

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    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 :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

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, 03:50 AM
  2. Heap Program Help
    By Rob4226 in forum C++ Programming
    Replies: 15
    Last Post: 05-02-2008, 02: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, 04:22 AM
  5. Cygwin GCC setting for heap
    By stlait00 in forum C Programming
    Replies: 1
    Last Post: 05-02-2006, 06:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21