Labdabeta 182 Posting Pro in Training Featured Poster

First of all realize how many elements you are storing, which is 115x4x114x114=5 978 160. Each element is a double, which is usually 64 bits (if I remember correctly) so 5 978 160x64=382 602 240 which is 382 megabits. Though this is well within the bounds of modern RAM, do be aware that you are storing quite a lot of data. Next you can use one of three techniques:

Technique 1: Real dynamically allocated multi-dimensional arrays:

This is a tricky one, but basically what you do is you realize that each array is a pointer, your array has 4 dimensions (it is an array of arrays of arrays of arrays of doubles) as such your new array is going to need 4 asterisks! Then you loop through each one useng the new operator to allocate your memory, like so:

double ****array;
//the following loops may be in reverse order, I cannot remember if you do 115-4-114-114 or 114-114-4-115
array=new double***[115];
for (int i=0; i<115; ++i)
{
    array[i]=new double**[4];
    for (int ii=0; ii<4; ++ii)
    {
        array[i][ii]=new double*[114];
        for (int iii=0; iii<114; ++iii)
            array[i][ii][iii]=new double[114];
    }
}

and now you can use array just as if it were as posted above.

Technique 2: Real multi-dimensional vector:

This is a bit less tricky, but do note that > > has a space between the symbols! Basically you make a vector of vectors of vectors of vectors of doubles.

vector<vector<vector<vector<double> > > > array;

Technique 3: Fake multi-dimensional vector + …

Labdabeta 182 Posting Pro in Training Featured Poster

I definately think that you should try debugging this. Windows gives the error your seeing usually when it has a sigseg fault. This means that at some point you get a NULL pointer and try using it as if it were not NULL (either dereferencing it manually, or passing it to a function that dereferences it). I would suggest adding checks the way that lazyfoo tutorials teaches (lazyfoo has great SDL tutorials) Here is what you should do for example at line 41-42 in main.cpp:

screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT,0,0);
if (screen==NULL)//uh-oh, error!
    return -1;//now if you see 'process finished with return value -1' you know that your screen didn't load!
claywin commented: So I should just do this with every line of code? One at a time? +0
Labdabeta 182 Posting Pro in Training Featured Poster

Obviously you do not understand. Let me see if I can explain. Take for example this class:

class myClass//it stores an int
{
    public:
    int myInt;
    myClass():myInt(0){}//default value is 0
    myClass(int i):myInt(i){}//you can set it on creation
    myClass(const myClass &o){myInt=o.myInt;}//copy constructor
};

This works fine, and it is the struct you are talking about. It is easy, I do not disagree! But lets say you have something like this:

class myVolatileClass//it stores an array of ints
{
    public:
    int *myInts;//stores an array of ints
    int numInts;//stores the number of ints in the array
    myClass():myInts(NULL),numInts(0){}//by default myInts is null and stores nothing
    myClass(int *ints, int num)//copies the array of ints
    {
        myInts=new int[num];
        for (int i=0; i<num; ++i)
            myInts[i]=ints[i];
        numInts=num;
    }
    myClass(const myClass &other)//a copy constructor
    {
        myInts=new int[other.numInts];
        for (int i=0; i<other.numInts; ++i)
            myInts[i]=other.myInts[i];
        numInts=other.numInts;
    }
    ~myClass()//this class requires a custom destructor to clean up the array
    {
        if (numInts>0)//if there are ints in the array
            delete[]myInts;//delete the array
    }
    int get(int index)//function to access a member of the array
    {
        if (index>=0&&index<numInts)//check that it is a valid index
            return myInts[index];
    }
    void add(int val)//add a value to the array
    {
        int *tmp=new int[numInts+1];//temporary storage for the new array
        for (int i=0; i<numInts; ++i)
            tmp[i]=myInts[i];
        tmp[numInts++]=val;
        if (numInts>0)
            delete[]myInts;
        myInts=tmp;
    }
};

Again this class is simple and works as you would expect... except look at this situation:

int main()
{
    int mydata[]={1,2,3};
    myVolatileClass c(mydata,3);
    //here we will cause an error:
    c.numInts=0;//trololol
    c.add(4);//sigseg here
    return 1;
}
Labdabeta 182 Posting Pro in Training Featured Poster

Check out this site.

Labdabeta 182 Posting Pro in Training Featured Poster

The thing is that you cannot (as far as I know) call main recursively (from within itself) and even if you can it is likely a bad idea (if the user wants to do 100 problems you will outrun your stack) The key is to use a loop. Here is an example for your code:

#include <stdio.h>
#include <conio.h>

main()

{
float choice,A,CUBE;
char temp;
bool exit=false;
while (!exit)//loop until we want to exit
{//I do not know why you put a block here... but I am using it :P
clrscr();
textcolor(BLUE);
gotoxy (24,5);
cprintf("SOLVE FOR THE FOLLOWING VOLUMES\n");
textcolor(345);
gotoxy (26,7);
cprintf("[1]   -    CUBE");
gotoxy (26,8);
cprintf("[2]   -    CONE");
gotoxy (26,9);
cprintf("[3]   -    SPHERE");
gotoxy (26,10);
cprintf("[4]   -    CYLINDER");
gotoxy (26,11);
cprintf("[5]   -    EXIT");
textcolor(RED);
gotoxy (24,14);
cprintf("Enter your choice:   ");
scanf("%f",&choice);

switch(choice)
{
case 1:
  {
    clrscr();
    textcolor (BLUE);
    gotoxy (30,5);
    cprintf("Volume of CUBE");

    textcolor (345);
    gotoxy (24,7);
    cprintf("Enter the side of the cube: ");
    scanf("%f",&A);

    CUBE=  (A*A*A);
    scanf("%2.0f,&CUBE");

    textcolor (345);
    gotoxy (24,10);
    cprintf("The Volume of the CUBE is %2.0f", CUBE);
  }
case 5://you do not NEED blocks after a case statement, but they can make your code look nicer
textcolor (RED);
gotoxy(24,14);
cprintf("Would you like to compute again(Y/N)? ");
scanf("%c", &temp);

exit = (!(temp == 'y' || temp == 'Y'));//set the exit variable
  }//end switch
 }//end while
return 0;
}//indentation would have told you that this bracket ends main
Labdabeta 182 Posting Pro in Training Featured Poster

The problem is on line 19 when you output an endl (newline) after the forward slash. Remove the endl and it should work fine.

Labdabeta 182 Posting Pro in Training Featured Poster

hit the 'x' just under the scroll bar for the source code viewing area. You can also find this 'x' by looking at the message you got and moving to the top-right of its box. I do not suggest getting rid of this necessarily as it is relatively important information.

Labdabeta 182 Posting Pro in Training Featured Poster

I cannot see the problem, but then again it is hard to read your code because you seem to have ignored modulation. In case you do not know, modulation is the practice of chunking your code together into separate functions so that they are easier to read. For example you could replace your code for showing the main menu with a showMenu() function. And the code that implements each menu option should also be a function. Your main should look more like this:

int main()
{
    initialize();//this is the section of your code up until the menu loop
    int menuChoice=showMenu();
    while (menuChoice>EXIT_CONDITION)//EXIT_CONDITION will be a macro, defined as 7 in your code
    {
        switch (menuChoice)
        {
            case DISPLAY_CONDITION://again DISPLAY_CONDITION is a macro
            displayRecords();
            break;
            //...
            default:
        }
    }
    return cleanUp();//maybe you need to do something to wrap up the program?
}

Writing the initialize() function and the showMenu() function etcetera is your job. This is just a general idea of proper programming style.

WaltP commented: That's modulARation. Modulation is changing the frequency of something. +17
Labdabeta 182 Posting Pro in Training Featured Poster

The problem is that you are sending ARRAY_SIZE to you sum and average functions. The issue is that the array may not be filled up all the way to ARRAY_SIZE. You need to pass numElements to those functions instead.

Labdabeta 182 Posting Pro in Training Featured Poster

I know that this #define QUOTE(X) #X turns X into a c-string version of whatever is passed to it. my question is if there is a way to do this in reverse ie: #define DEQUOTEANDCALLFUNCTIONORCLASSWITHGIVENNAME(X) (X#)() is this possible?

Labdabeta 182 Posting Pro in Training Featured Poster

Ill try to help, but please put CODE tags around your code so I can read it.