Click here to Skip to main content
15,897,291 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow do I specify CView's size? Pin
Anonymous10-Dec-02 17:41
Anonymous10-Dec-02 17:41 
GeneralSQL Server ODBC with ADO Pin
Exceter10-Dec-02 16:55
Exceter10-Dec-02 16:55 
GeneralRe: SQL Server ODBC with ADO Pin
Anonymous10-Dec-02 17:53
Anonymous10-Dec-02 17:53 
GeneralRe: SQL Server ODBC with ADO Pin
carrie10-Dec-02 21:11
carrie10-Dec-02 21:11 
Questionstring replace function? Pin
trustno110-Dec-02 15:00
trustno110-Dec-02 15:00 
AnswerRe: string replace function? Pin
carrie10-Dec-02 15:09
carrie10-Dec-02 15:09 
GeneralRe: string replace function? Pin
trustno110-Dec-02 17:27
trustno110-Dec-02 17:27 
Questionprogram crashes after execution??? why? Pin
Joisme10-Dec-02 14:17
Joisme10-Dec-02 14:17 
Below are three files, two .cpp files and one .h file. The program runs no problem and does exactly what it is supposed to do but right after it executes it crashes and I cannot figure out why. I have tried to figure this out with someone in my class and he cannot figure it out either. Anyone out there who can figure it out for me????? It crashes on a Win XP machine, btw, if that makes any difference. Thanks. Jo
_________________________________________________________________________________

//header
#ifndef BrandesJF1CIS32B02FD_h
#define BrandesJF1CIS32B02FD_h

class DoubleArray //define class
{
public:
DoubleArray (); //constructor
int &operator() (const int, const int); //overloaded () operator
void PrintArray(); //output data

private:
int array[8][8]; //the 8x8 array

};

#endif

____________________________________________________________________________________

//source
#include "BrandesJF1CIS32B02FD.h"
#include <iostream.h>

DoubleArray::DoubleArray ()
{
for (int rows = 0; rows <=8; rows++) //propogate initial board
{
for (int columns = 0; columns <=8; columns++)
{
array[rows][columns] = columns;
}
}

cout << " The initial board's data\n";
cout << " ________________________\n\n";

DoubleArray::PrintArray(); //display initial board
}

int &DoubleArray::operator() (const int row, const int column) //operator () function def.
{
return array[row][column];
}

void DoubleArray::PrintArray() //PrintArray function definition
{

cout << " 0 1 2 3 4 5 6 7\n";
cout << " ____________________________________\n";

for (int rows = 0; rows <= 7; rows++)
{
cout << " " << rows << "|";
for (int columns = 0; columns <= 7; columns++)
{
if ((array[rows][columns]) < 0)
{
cout << " " << array[rows][columns];
}
else
{
cout << " " << array[rows][columns] << (columns == 7 ? "\n" : "");
}
}
}

cout.flush();

}

______________________________________________________________________________________

//source 2
#include "BrandesJF1CIS32B02FD.h"
#include <iostream.h>
#include <windows.h>

void setcolor(unsigned short); //function prototype for color

main ()
{
DoubleArray board;

setcolor(12); //change color of calculating and final board ONLY
cout << "\nCalculating......\n\n";
cout << "1. board(0,0)=board(0,1)+board(0,7)\n";
cout << "2. board(1,0)=board(1,1)-board(1,7)\n";
cout << "3. board(2,0)=board(2,1)*board(2,7)\n";
cout << "4. board(3,0)=board(3,6)/board(3,2)\n";
cout << "5. board(4,0)+=board(4,7)\n";
cout << "6. board(5,0)-=board(5,7)\n";
cout << "7. board(6,0)++\n";
cout << "8. board(6,0)*=board(6,7)\n";
cout << "9. board(7,0)=7\n";
cout << "10. board(7,0)/=board(7,1)\n\n";

board(0,0)=board(0,1)+board(0,7); //calculates data
board(1,0)=board(1,1)-board(1,7);
board(2,0)=board(2,1)*board(2,7);
board(3,0)=board(3,6)/board(3,2);
board(4,0)+=board(4,7);
board(5,0)-=board(5,7);
board(6,0)++;
board(6,0)*=board(6,7);
board(7,0)=7;
board(7,0)/=board(7,1);

cout << " The final board's data\n";
cout << " _______________________\n\n";


board.PrintArray(); //prints out new board

cout << endl;

return 0;
}

void setcolor(unsigned short color) //color function
{
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon,color);
}
______________________________________________________________________________________
AnswerRe: program crashes after execution??? why? Pin
Chris Losinger10-Dec-02 14:21
professionalChris Losinger10-Dec-02 14:21 
GeneralRe: program crashes after execution??? why? Pin
Joisme10-Dec-02 14:23
Joisme10-Dec-02 14:23 
GeneralRe: program crashes after execution??? why? Pin
Chris Losinger10-Dec-02 14:29
professionalChris Losinger10-Dec-02 14:29 
GeneralRe: program crashes after execution??? why? Pin
Joisme10-Dec-02 14:33
Joisme10-Dec-02 14:33 
GeneralRe: program crashes after execution??? why? Pin
Chris Losinger10-Dec-02 14:35
professionalChris Losinger10-Dec-02 14:35 
GeneralRe: program crashes after execution??? why? Pin
Alvaro Mendez10-Dec-02 14:33
Alvaro Mendez10-Dec-02 14:33 
GeneralRe: program crashes after execution??? why? Pin
Joisme10-Dec-02 14:41
Joisme10-Dec-02 14:41 
AnswerRe: program crashes after execution??? why? Pin
Ted Ferenc10-Dec-02 21:58
Ted Ferenc10-Dec-02 21:58 
GeneralAutomaion question Pin
Martin Marvinski10-Dec-02 10:55
Martin Marvinski10-Dec-02 10:55 
GeneralRe: Automaion question Pin
Shog910-Dec-02 12:25
sitebuilderShog910-Dec-02 12:25 
Questiongina problem? Pin
imran_rafique10-Dec-02 9:30
imran_rafique10-Dec-02 9:30 
AnswerPlease, I beg you all.... Pin
Christian Graus10-Dec-02 15:19
protectorChristian Graus10-Dec-02 15:19 
GeneralRe: Please, I beg you all.... Pin
Anonymous10-Dec-02 15:27
Anonymous10-Dec-02 15:27 
GeneralRe: Please, I beg you all.... Pin
Andreas Saurwein13-Dec-02 3:57
Andreas Saurwein13-Dec-02 3:57 
Generalplz ans Pin
imran_rafique10-Dec-02 9:28
imran_rafique10-Dec-02 9:28 
GeneralRe: plz ans Pin
Neville Franks10-Dec-02 10:20
Neville Franks10-Dec-02 10:20 
Questiongina logon? Pin
imran_rafique10-Dec-02 9:24
imran_rafique10-Dec-02 9:24 

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.