Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionStrings [SOLVED] Pin
goldenrose914-Feb-11 19:24
goldenrose914-Feb-11 19:24 
AnswerRe: Strings Pin
ShilpiP14-Feb-11 19:53
ShilpiP14-Feb-11 19:53 
GeneralRe: Strings Pin
goldenrose914-Feb-11 21:59
goldenrose914-Feb-11 21:59 
GeneralRe: Strings Pin
ShilpiP14-Feb-11 22:15
ShilpiP14-Feb-11 22:15 
GeneralRe: Strings Pin
goldenrose914-Feb-11 23:26
goldenrose914-Feb-11 23:26 
GeneralRe: Strings Pin
ShilpiP14-Feb-11 23:29
ShilpiP14-Feb-11 23:29 
AnswerRe: Strings Pin
CPallini14-Feb-11 21:32
mveCPallini14-Feb-11 21:32 
QuestionCorruption of the Heap Error Pin
Foothill14-Feb-11 10:40
professionalFoothill14-Feb-11 10:40 
To begin, I'm enrolled a some programming classes at the my university, so I'm getting my C++ feet wet through experimentation. The following code generates a heap corruption error everytime I launch it.


#include<iostream>
using namespace std;

struct IntArray
{
int Iarray[0];
};

void main()
{

char end;
short num = 20;

IntArray* A = (IntArray*)new int(sizeof num);

for ( short i = 0 ; i < 10 ; ++i )
{
A->Iarray[i] = ( i * 10 );
}

for ( short j = 0 ; j < 10 ; ++j )
{
cout << A->Iarray[j]," ";
}

cin >> end;

delete A;

return;
}

This is the error that it generates before the program even starts to run:

"Windows has triggered a breakpoint in My Arrays.exe.
This may be due to a corruption of the heap, which indicates a bug in My Arrays.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while My Arrays2.exe has focus.
The output window may have more diagnostic information."

I following the exact procedures found in the MSDN article:
http://msdn.microsoft.com/en-us/library/0scy7z2d(VS.80).aspx

I'm trying to build array methods that I can understand.
Any idea on where I screwed this up will be helpful to the learning process.
AnswerRe: Corruption of the Heap Error Pin
David Crow14-Feb-11 11:55
David Crow14-Feb-11 11:55 
GeneralRe: Corruption of the Heap Error Pin
Foothill14-Feb-11 14:26
professionalFoothill14-Feb-11 14:26 
GeneralRe: Corruption of the Heap Error Pin
David Crow14-Feb-11 17:11
David Crow14-Feb-11 17:11 
GeneralRe: Corruption of the Heap Error Pin
ShilpiP14-Feb-11 19:13
ShilpiP14-Feb-11 19:13 
AnswerRe: Corruption of the Heap Error Pin
ShilpiP14-Feb-11 19:11
ShilpiP14-Feb-11 19:11 
AnswerRe: Corruption of the Heap Error Pin
Niklas L14-Feb-11 21:17
Niklas L14-Feb-11 21:17 
AnswerRe: Corruption of the Heap Error Pin
Stefan_Lang15-Feb-11 6:52
Stefan_Lang15-Feb-11 6:52 
GeneralRe: Corruption of the Heap Error Pin
Niklas L15-Feb-11 10:54
Niklas L15-Feb-11 10:54 
GeneralRe: Corruption of the Heap Error Pin
Stefan_Lang15-Feb-11 22:10
Stefan_Lang15-Feb-11 22:10 
GeneralRe: Corruption of the Heap Error [modified] Pin
Niklas L15-Feb-11 22:37
Niklas L15-Feb-11 22:37 
GeneralRe: Corruption of the Heap Error Pin
Stefan_Lang15-Feb-11 22:51
Stefan_Lang15-Feb-11 22:51 
GeneralRe: Corruption of the Heap Error [modified] Pin
Niklas L15-Feb-11 23:13
Niklas L15-Feb-11 23:13 
GeneralRe: Corruption of the Heap Error Pin
Niklas L16-Feb-11 6:57
Niklas L16-Feb-11 6:57 
GeneralRe: Corruption of the Heap Error Pin
Stefan_Lang16-Feb-11 22:22
Stefan_Lang16-Feb-11 22:22 
GeneralRe: Corruption of the Heap Error Pin
Niklas L16-Feb-11 23:12
Niklas L16-Feb-11 23:12 
GeneralRe: Corruption of the Heap Error Pin
Stefan_Lang17-Feb-11 1:10
Stefan_Lang17-Feb-11 1:10 
GeneralRe: Corruption of the Heap Error Pin
Niklas L17-Feb-11 1:34
Niklas L17-Feb-11 1:34 

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.