Click here to Skip to main content
15,899,126 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralHelp!! .Net building errors Pin
Anonymous24-Oct-03 10:36
Anonymous24-Oct-03 10:36 
Generaltrying to make a rainbow out of a palette Pin
ns24-Oct-03 10:29
ns24-Oct-03 10:29 
GeneralRe: trying to make a rainbow out of a palette Pin
igor196024-Oct-03 11:05
igor196024-Oct-03 11:05 
GeneralRe: trying to make a rainbow out of a palette Pin
Ravi Bhavnani25-Oct-03 17:40
professionalRavi Bhavnani25-Oct-03 17:40 
GeneralRe: trying to make a rainbow out of a palette Pin
ns3-Nov-03 5:23
ns3-Nov-03 5:23 
QuestionHow to hide a tab from the Property Sheet Pin
ElizabethC24-Oct-03 10:18
ElizabethC24-Oct-03 10:18 
AnswerRe: How to hide a tab from the Property Sheet Pin
vcplusplus24-Oct-03 15:38
vcplusplus24-Oct-03 15:38 
GeneralArrays, heap, delete and crash! Pin
Rickard Andersson2024-Oct-03 10:03
Rickard Andersson2024-Oct-03 10:03 
I'm trying to move values in an array downwards.
This is just example code and I can't make it working:

char** t = new char*[5];
void move();
void print_data();

int main()
{
  char* e1 = "one";
  char* e2 = "two";
  char* e3 = "three";
  char* e4 = "four";
  char* e5 = "five";

  t[0] = e1;
  t[1] = e2;
  t[2] = e3;
  t[3] = e4;
  t[4] = e5;

  print_data();
  std::cout << "------------------------\n";
  move();
  print_data();

  delete [] t; // Crash here!
  return 0;
}

void move()
{
  // Begin at the end of the array and then move upwards
  for(int i = 5; i >= 0; i--)
  {
    char* temp = NULL;
    if(i == 0) // Is this clear what it does?
      temp = nada;
    else
      temp = t[i-1];

    t[i] = temp;
  }
  t[0] = "new value at first position";
}

void print_data()
{
  for(int i = 0; i < 5; i++)
    std::cout << i+1 << " -> " << t[i] << "\n";
}


When the program tries to delete t it crashes with this debug info:
DAMAGE: after normal block (#bla bla) at 0xbla bla.

Well, I guess it's useless but how can I solve this?
And please, don't ask why I'm doing this Smile | :)

Rickard Andersson
Here is my card, contact me later!

UIN: 50302279
Sonork: 37318

GeneralRe: Arrays, heap, delete and crash! Pin
Alexander M.,24-Oct-03 10:08
Alexander M.,24-Oct-03 10:08 
GeneralRe: Arrays, heap, delete and crash! Pin
Rickard Andersson2024-Oct-03 10:17
Rickard Andersson2024-Oct-03 10:17 
GeneralRe: Arrays, heap, delete and crash! Pin
Gary R. Wheeler25-Oct-03 4:18
Gary R. Wheeler25-Oct-03 4:18 
GeneralRe: Arrays, heap, delete and crash! Pin
Kelly Herald24-Oct-03 10:52
Kelly Herald24-Oct-03 10:52 
GeneralRe: Arrays, heap, delete and crash! Pin
Rickard Andersson2024-Oct-03 11:00
Rickard Andersson2024-Oct-03 11:00 
GeneralRe: Arrays, heap, delete and crash! Pin
igor196024-Oct-03 10:55
igor196024-Oct-03 10:55 
GeneralClass Wizard Problem Pin
ElizabethC24-Oct-03 9:20
ElizabethC24-Oct-03 9:20 
GeneralRe: Class Wizard Problem Pin
ElizabethC24-Oct-03 10:17
ElizabethC24-Oct-03 10:17 
GeneralYUV image format Pin
Raphael Kindt24-Oct-03 7:05
Raphael Kindt24-Oct-03 7:05 
GeneralRe: YUV image format Pin
David Crow24-Oct-03 8:29
David Crow24-Oct-03 8:29 
GeneralBUG: Registration of Attributed ATL Component fails with Web References Pin
arun140524-Oct-03 6:41
arun140524-Oct-03 6:41 
QuestionHow to overcome the 32K size limit in CFileDialog? Pin
Ted94424-Oct-03 5:34
Ted94424-Oct-03 5:34 
AnswerRe: How to overcome the 32K size limit in CFileDialog? Pin
David Crow24-Oct-03 6:19
David Crow24-Oct-03 6:19 
GeneralRe: How to overcome the 32K size limit in CFileDialog? Pin
Ted94424-Oct-03 6:33
Ted94424-Oct-03 6:33 
AnswerRe: How to overcome the 32K size limit in CFileDialog? Pin
valikac24-Oct-03 6:39
valikac24-Oct-03 6:39 
GeneralRe: How to overcome the 32K size limit in CFileDialog? Pin
Ted94424-Oct-03 7:23
Ted94424-Oct-03 7:23 
GeneralDirect x Pin
Member 64940724-Oct-03 5:26
Member 64940724-Oct-03 5:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.