sfuo 111 Practically a Master Poster

You can use System.IO.Directory.GetFiles(DIRECTORY_NAME); which will return an array of strings that contain all the files (with full path) in that folder.

PulsarScript commented: Thank you +2
sfuo 111 Practically a Master Poster

I know this is a bit late and you may have come up with a solution already but here is a method you could use.

pbGameBox is a PictureBox object from the C# Toolbox.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace dani_mapEditor
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        void onTick(object sender, EventArgs e)
        {
            Point P = PointToScreen(new Point(pbGameBox.Bounds.Left, pbGameBox.Bounds.Top));
            Int32 X = Cursor.Position.X - P.X;
            Int32 Y = Cursor.Position.Y - P.Y;

            if (X < 0 || Y < 0 || X > pbGameBox.Bounds.Width || Y > pbGameBox.Bounds.Height)
                this.Text = "--, --";
            else
                this.Text = String.Format("{0}, {1}", X, Y);

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Timer aTimer = new Timer();
            aTimer.Interval = 10;
            aTimer.Tick += new EventHandler(onTick);
            aTimer.Enabled = true;

            GC.KeepAlive(aTimer);



        }
    }
}

All this does is updates the title of the window (with the use of a timer) to the X, Y coordinates of the mouse within the PictureBox. If the mouse is out of bounds of the PictureBox then it just displays "--, --".

sfuo 111 Practically a Master Poster

I am not a Unix/Linux user so I am not 100% sure but after reading on GetOpt here and a GetOpt example here I would say the short answer is you must write myprogram.c -t file1 file2 file3 because it parses for options first.

sfuo 111 Practically a Master Poster

Line 18 of what you posted makes no sense. It will always select maximum = maximum in the trinary operator and you cannot declare a variable equal to an undeclared variable (even if you could it would be holding a garbage value).

Line 19 you are now saying that the low guess is equal to some mystery value and your high guess is the maximum tolerated error? and then your maxError is now set to 0 and never used within your helper function.

In your helper function the only two lines that make sense are the first two where you calculate the average and the resulting fifth power of that value. Other than that I do not fully understand what you are trying to do because fifthPower - x will not give anything useful the way you are using it (maybe if you used maxError in here somewhere then it would make sense, but then again you are setting that to 0.0).

Here is what I think you are attempting to do

#include <iostream>
#include <cmath>

using namespace std;

double fifthRootHelper(double x, double maxError, double low, double high)
{
    if (x == 1.0) //special case for 1.0
        return 1.0;

    double avg = (low + high) / 2.0;  //use 2.0 not 2 just for the future case of running into integer division without knowing
    double fifthPower = avg*avg*avg*avg*avg;

    if (fabs(fifthPower - x) < maxError) //if our new guess is within our error, return that as the answer
        return avg;

    if …
sfuo 111 Practically a Master Poster

I would suggest that you do not try to store all your information in labels, but rather have seperate variables that control the amount of each stat that your character has and then display those values in the labels.

I tossed together a quick example of how you can use buttons to increase and decrease the stats for your character. I am sure there are better ways of coding this but this should get you on track and going.

UI is here - http://i.imgur.com/zS0hM22.png

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DaniRPG
{
    public partial class Form1 : Form
    {
        Player me;
        Int32 remainingPoints;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            me = new Player();
            remainingPoints = 20;

            lblAgiPts.Text = me.Agility.ToString();
            lblIntPts.Text = me.Intelligence.ToString();
            lblStrPts.Text = me.Strength.ToString();
            lblStamPts.Text = me.Stamina.ToString();
            lblRemainingPts.Text = remainingPoints.ToString();
        }

        private void btnStrInc_Click(object sender, EventArgs e)
        {
            if (remainingPoints > 0)
            {
                me.Strength++;
                remainingPoints--;
                lblStrPts.Text = me.Strength.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }

        private void btnStrDec_Click(object sender, EventArgs e)
        {
            if (me.Strength > 0)
            {
                me.Strength--;
                remainingPoints++;
                lblStrPts.Text = me.Strength.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }

        private void btnAgiInc_Click(object sender, EventArgs e)
        {
            if (remainingPoints > 0)
            {
                me.Agility++;
                remainingPoints--;
                lblAgiPts.Text = me.Agility.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }

        private void btnAgiDec_Click(object sender, EventArgs e)
        {
            if (me.Agility > 0)
            {
                me.Agility--;
                remainingPoints++;
                lblAgiPts.Text = me.Agility.ToString();
                lblRemainingPts.Text = remainingPoints.ToString();
            }
        }

        private void btnIntInc_Click(object sender, EventArgs e)
        {
            if …
sfuo 111 Practically a Master Poster

Just a question.
Could you tell me how you thought this:

a[maxIndex] = a[r*N + r];

I mean the index r*N + r.
As I can see it gives the diagonal elements.
I didn't know about that!

The diagonal elements occur when the row index is equal to the column index. We use "r" in this case because we are iterating through the rows with the outer most for loop. If you write the matrix out on paper and try to come up with general solutions using only constants (N in this case) and variables that you are controling (r and c), you can come up with equations that you can input directly into your code.

Also, do you have a solution using the max value instead of the max index?

Because ,I can't figure why I couldn't get the proper max value.

You could use the max value but you will have to keep track of the column index of the max value (unless you want to scan through the columns after finding the max value to find it again and do the swap, which I think is a bad idea).

for (int r = 0; r < N; r++)
{
    //"Assume" maxValue is the first element of the row
    double maxValue = fabs(a[r*N]);
    int col = 0;

    //Check to see if the rest of the elements are greater than current max value
    for (int c = 1; c < N; …
sfuo 111 Practically a Master Poster

Not sure why you are switching values in the b array or why your swap function uses loops.

#include <iostream>
using namespace std;

int main()
{
    const int N = 3;
    double *a = new double[N*N];
    double *b = new double[N];
    double *x = new double[N];

    a[0] = 9;
    a[1] = 3;
    a[2] = 1;
    a[3] = 0;
    a[4] = 4;
    a[5] = 5;
    a[6] = 8;
    a[7] = 1;
    a[8] = 4;

    b[0] = 7;
    b[1] = 8;
    b[2] = 9;

    cout << "Before" << endl;
    for (int r = 0; r < N; r++)
    {
        for (int c = 0; c < N; c++)
            cout << a[r*N + c] << " ";
        cout << b[r] << endl;
    }

    cout << endl;

    for (int r = 0; r < N; r++)
    {
        //"Assume" maxIndex is the first element of the row
        int maxIndex = r*N;

        //Check to see if the rest of the elements are greater than current max index
        for (int c = 1; c < N; c++)
        {
            //If it is greater then set the max index to the current index
            if (fabs(a[r*N + c]) > fabs(a[maxIndex]))
                maxIndex = r*N + c;
        }

        cout << "Max = " << fabs(a[maxIndex]) << " idx = " << maxIndex - r*N << endl;

        //If the max index is not a diag then lets switch it
        if (maxIndex - r*N != r) //col != row aka diag
        {
            double tmp = a[maxIndex];
            a[maxIndex] = a[r*N + r];
            a[r*N + …
sfuo 111 Practically a Master Poster

Do you mean the constructor?

You make a public function within the class that has no return (not void) and also has the same name as the class.

#include <iostream>
using namespace std;

class Square
{
    int _side;

public:

    Square(){};

    Square(int side)
    {
        _side = side;
    }
};

int main()
{
    Square aSquare;
    Square bSquare(10);

    return 0;
}
sfuo 111 Practically a Master Poster

Line 17 should be display->array = (char **) malloc(sizeof(char*) * height);
Note that it is sizeof(char*) not sizeof(char) because you are trying to allocate char pointers which have a size of 4, where a char has a size of 1.

Also your display function will not work as intended because you did not null-terminate your char arrays ('\0'). You can either null-terminate them or print the arrays out char by char, opposed to trying to print each line using the c-string format option in printf.

sfuo 111 Practically a Master Poster

If your function is always going to be composed of A*x^0 + B*x^1 + ... N*x^n then why don't you integrate the function analytically and then evaluate it at the bounds x1 and x2 and subtract them.
example:
f(x) = 10x - 5x^2
x1 = 1, x2 = 5
int(f(x)) = (10/2)x^2 - (5/3)x^3 + C
int(f(5)) - int(f(1)) = Area under curve
((10/2)*5^2 - (5/3)*5^3 + C) - ((10/2)*1^2 - (5/3)*1^3 + C) = Area under curve
Note C-C = 0 so we do not need to solve for C

This method will give you the exact answer rather than a numerical approximation found using rectangle/triangle/simpsons methods.

Coding power rule integration is really easy because it follows an easy form, with the exception of int(x^-1) which is ln(x) + C.
Note ln(x) in C/C++ is log(x) and log(x) is log10(x)

The form is:
f(x) = A*x^n
int(f(x)) = (A/(n+1))*x^(n+1) + C

Because you are always going to be evaluating between two bounds, you can ignore the whole + C part of the integration in your code.

Using this analytical method in your code will not require many changes other than adding a function that will integrate the function input by the user. You can also use a similar function to findHeightOfFunction() that just evaluates the integrated function at a specific point.

As for your findHeightOfFunction() function, you are on the right track with the whole loop idea and the line of code you have that multiplies the coeff …

sfuo 111 Practically a Master Poster

int compare (const void * a, const void * b)
The two values 'a' and 'b' are of type void pointer and we want this function to compare two integers so we must convert from void pointers to integers.

To do this we first cast the void pointer into an integer pointer.
(int*)a This leaves us with a pointer to an integer

Next we want to get the value in which the integer pointer is looking at by dereferencing the pointer with '*'.

*(int*)a This will convert the void pointer into an integer pointer, then dereference the integer pointer and leave us with an integer.

You could break this up in such a way that it is very clear to see what is going on but basically all that is happening here is a cast and a dereference all done on one line.

sfuo 111 Practically a Master Poster

You would have to use a custom data type. A double can only hold so much precision.

sfuo 111 Practically a Master Poster

If you want to make a console application (the black cmd window) you select the Win32 Console Application project type. If you do not want the console to show then you create a Win32 Project, if you are using SDL or GLUT then you can call some of their library functions to create a window and then you just pass in functions into a callback that they specify (if you follow a tutorial you will figure out what I'm talking about). If you do not use SDL or GLUT (or similar library bundles) then you will have to look into WinAPI and it is not fun because it is written in C and has all of Window's custom data types and functions.

I'm going to assume that you are starting with SDL. If you read Lazy Foo's first tutorial and select Window > Visual Studio 2010, he gives you a step by step of what you need to do to get started.

sfuo 111 Practically a Master Poster

Since you have just recently started learning C++ and I don't know what programming background you have. I would suggest that you learn the foundations of the language before moving on to graphics.

While you are learning the lanuage you should think of really basic "games" that you could complete in a console window (i.e. tic-tac-toe, blackjack, and other easy card games). These games will help you by making you use a many parts of the C++ language all together.

After you feel more comfortable with the language then you should really think about what IDE and graphics library you want to use. Alternativly you can use a game engine that will handle graphics, physics, sound, GUIs, and much more, but this depends on if you actually want to learn how to program or just make games that are bound by their engine. Personally I like to try to make my own "libraries" with the exception of a graphics library because that would be just crazy.

I use OpenGL and VS2012, however if you are just starting out I would suggest using SDL or another "simplified" graphics library. This way you are not spending lots of time learning the graphics library and instead you can focus on learning how to use the language and understand how a game works.

Here is the C++ tutorial website that I used to learn the language and I still use this website as a reference for the standard libraries.

Here

sfuo 111 Practically a Master Poster

Do you not have a main() function in your program? If what you posted is your program and not just a snippet then you need to throw in main().

sfuo 111 Practically a Master Poster

If you are new to game programming then you should start with a 2D game. There is a massive gap between 2D and 3D if you plan on writing any of your own code (physics or other engine elements).

sfuo 111 Practically a Master Poster

strcpy() works with c-strings and those are arrays of characters that have a '\0' terminating character. You are using a C++ string and they have the '=' operator overloaded so you just have to write string1 = string2; and that will copy the contents of string2 into string1.

I would not use strcpy() and I wouldn't make a new string variable 'x'. It looks like you could just write cin >> temp->TeamName; and that would work the way you want it.

sfuo 111 Practically a Master Poster

If you have the function prototypes within the class and you want to define them outside, you need to define them with the proper scope.

Right now you are just declaring some functions in the global scope. To define the class's functions you need to include the scope of the class in the function definition.

For example:

void BitPattern::ReadBitPattern (ifstream& infile)
{
    char ch;

    if(ch == '0')
    {
        for (int index = 0; index < PatternSize; index++) 
        {
            cin.get (ch);
        }
    }

    else 
    {
        for (int index = 0; index < PatternSize; index++)
        {

        }
    }
}

Notice how BitPattern:: is before the function name?

sfuo 111 Practically a Master Poster

why do you have the return 0; line out of main()?

sfuo 111 Practically a Master Poster

You will also find that your setDriver() and setOwner() functions will cause a crash. To fix this you can do the following.

//called in main()
carPtr->setDriver(people[personNum]);
carPtr->setOwner(people[personNum]);

//in Car class
void setDriver(Person *d)
{
    driver = d;
}
void setOwner(Person *o)
{
    owner = o;
}
sfuo 111 Practically a Master Poster

Well line 86 is going to have the same problem.

sfuo 111 Practically a Master Poster

You obviously didn't read the other thread that you started. I posted code that would output what that is and I said it is not a word or words it is just junk.

sfuo 111 Practically a Master Poster

If you don't want to use the table you can just use a program to print out what the char for those hex values would be.

#include <iostream>
using namespace std;

int main()
{
    char message[] = { 0x4B, 0x50, 0x7B, 0xF1, 0xF4, 0xF5, 0x5E, 0x50, 0x7B, 0xF1, 0xF4, 0xF5, 0x5E, 0x4B, 0x4B, 0x4B };

    for( int i = 0; i < 16; i++ )
        cout << message[i];
    cout << endl;

    cin.get();
    return 0;
}

The message is junk but maybe you can make something out of it. I'll let you run it and see what it is.

sfuo 111 Practically a Master Poster

We are asking you to post code. We will not help you unless you show that you have done some work.

sfuo 111 Practically a Master Poster

So if you were to go based off my previous post you would pick option #3.

This would be pretty much instant because all the minimum number locations and values have already been saved into an array.

Another approach to this would be to do as deceptikon and pyTony suggested, which is sorting the list and then iterating to the kth element of the sorted list. This would take a bit longer since you have to sort a list that could be very large. However I haven't actually bothered with sorting large containers so I wouldn't know if it would be that big of an issue.

sfuo 111 Practically a Master Poster

How about you post up some code and then show us exactly where you are having problems. Writing out a big mal-formed paragraph isnt going to make us help you.

sfuo 111 Practically a Master Poster

At any point of time, I am asked to return the kth(it is given initally) minimum element from the elements read so far.

When I read this I can interperet it three different ways:
1) You are at the 'kth' element and you want to know what the minimum element so far is
2) You are at the 'kth' element and you want to know what the minimum element at any point before the 'kth' point is
3) You are at the 'kth' element and you want to know what the 'nth' minimum element is (eg numbers are 10, 9, 11, 14, 15, 8 -- 3rd minimum element would be 8)

The first option would be very easy since you would just read in and check if the current minimum is less than the read in value, if not then the read in value is the new minimum.

The second option would require you to keep a history of some sort which tells you where the minimum changed and what it became, then you would have to find the point that is less than or equal to the 'kth' element.

The third option would be like the second option but instead of checking where it changed you just access the history array (or other container) at the 'kth' index.

When asking questions you have to be clear as to what is going on.

sfuo 111 Practically a Master Poster

If you were to throw return user; at the bottom of your function the error would go away. This is because if for some reason it did not go into your using statements it would never see a return statement.

sfuo 111 Practically a Master Poster

Or instead of using an int array you could use a map (or unordered_map if you have a compiler that supports C++11).

Accessing the values would be exactly the same but instead of having an array with a size of 97 + 26 (because 'a' is 97 (as said above) and then you need room up until 'z') you would have a map with 26 entries. Obviously maps have overhead that a normal array does not, but I think it would be good to play around with some of the STL containers so that you know how to use them and what each of them can and cannot do.

#include <iostream>
#include <map>

using namespace std;

int main()
{
    map<char, int> myMap;

    for( int i = 0; i < 26; i++ )
        myMap['a'+i] = i;

    cout << myMap['c'] << endl;

    cin.get();
}

By the way (I'm sure you just wrote it out and didn't actually test it) you defined an int array of size 10 but assigned/accessed out of bounds (in your second example).

DeanMSands3 commented: While NathanOliver and AncientDragon give "correct" answers, this is probably the most useful. +5
sfuo 111 Practically a Master Poster

All three errors are from line 23 in your original post. If you read my post then you should have been able to correct that line and you would not have any more errors.

sfuo 111 Practically a Master Poster

There are a few things wrong with your code and you can make a few improvements too.

You are getting those errors because your syntax is wrong. If you wanted to input that equation it should look like cout << (storage_f_to_c - 32.0f)*5.0f/9.0f << endl;. So not only is the equation incorrect, but you had the multiplication operator with a closing bracket to the left (you would never see this in written math or input for a computer). Another problem is that you have "<<" at the end of the line and that is looking for a right-hand operand.

Some imporovements that you could make would be to use a variable like "input" to store both enter_f_to_c and enter_c_to_f (and if you were to expand this to Kelvin and Rankine then you would need loads more variables), also should make "result" hold the storage variations of these variables and the variables enter, a, and b can go into a single char variable called "option" and to select which equation to use you can check it with a switch() statement.

#include <iostream>
#include <cmath> //in C++ use cmath not math.h (this goes for all the standard .h headers from C)

using namespace std;

int main()
{
    char option;
    float input;
    float result = 0.0f;

    cout << "If you would like to convert Fahrenheit to Celsius,\n type the lowercase letter -a- (without the hyphens).\n If you would like to convert Celsius to Fahrenheit\n type the lowercase letter -b- (without hyphens).\n You …
sfuo 111 Practically a Master Poster

I find it funny how you are just spam posting really short questions and not really going into any detail. No one will help you if you don't do a bit of work and show us that you have done a bit of research on your end.

sfuo 111 Practically a Master Poster

When making a game I normally make a win32 window application and use SetTimer() to create a timer and then put the code that I want to be executed inside the windows message loop. I'm not 100% sure if this is any different in the end.

I have not tested this out, since I use the windows message loop, but you can try to call SetTimer() with the last parameter pointing to a function that you want to be called when the timer expires.

I would have to agree with you and say that it probably is a bad thing to run an infinite loop that checks clock() against a value to see if it is time to execute your code within. A solution to this would be to put a short delay at the end of the while() loop (I think the minimum value you can pass is 10ms) which would allow the CPU to do other tasks.

sfuo 111 Practically a Master Poster

I tried to edit the above post but it didn't go through, and now I'm locked out of editing it.

Anyways the inner while() loop should be an if() statement.

sfuo 111 Practically a Master Poster

while( clock() < end_time ) ;

Sorry, but that's a horrible suggestion as it consumes all the cpu time leaving little or nothing for other windows programs.

Would this result in hogging the CPU too? I use this lots and after reading this I am wondering how else you might do this.

#include <ctime>
#include <iostream>

using namespace std;

int main()
{
    time_t startTime = clock();
    time_t check = 0;
    while(1) //program main loop
    {
        time_t check = float(clock() - startTime)/CLOCKS_PER_SEC*1000;
        while( check >= 5 ) //after 5 milliseconds have elapsed
        {
            cout << check << endl;
            startTime = clock();
            check = 0;
        }
    }

    cin.get();
    return 0;
}

I put in the check variable just to output the time in milliseconds.

sfuo 111 Practically a Master Poster

When I used SDL for graphics I don't ever remember using SDL_GetKeyState(); however, it could have been just a preference that the writer turtorials I followed had.

My suggestion (it might not be the best option) is to create your own bool array to manage the key states. You can do this by calling SDL_PollEvent() and when SDL_KEYDOWN/UP is called set the key states to true/false respectivly. The major issue that I see with this is that num lock, caps lock and scroll lock all are toggled rather than having momentary states like all the other keys. So you can treat this as a special case or just ignore it if you do not plan on using those keys for anything.

The other things that I added was a fps timer since using SDL_Delay() actually freezes the program up and I changed the starting speed for the player because you cannot move with a starting value of 0.

I didn't change the whole increasing speed method but I think having to press the space bar 5 times before you notice any change is a bit odd.

"main.cpp"

#include <cstdlib>
#include <ctime> //for the timer

using namespace std;
#include <SDL.h>

#include "playertank.h"

int main ( int argc, char** argv )
{
    SDL_Init(SDL_INIT_VIDEO);

    unsigned int curTime = clock(); //used for fps timer rather than using delay

    bool keys[SDLK_LAST]; //array of keystates

    //you might want to set the initial states to that of what SDL_GetKeyState finds
    //since for some reason it could find …
sfuo 111 Practically a Master Poster

What that means is that you do not have a main() function present in your code.

I have a feeling that you are trying to compile just this file on its own. What you need to do is include this file in a project that has a main() function and then compile that. If you want to use this all on its own (I don't think this is the case because you have #define guards at the top of your code) then you need to create a main() function.

sfuo 111 Practically a Master Poster

Actually the code post is exactly what you wanted for the whole conversion from one base to another. This is just set to hex, if you want to it be general then replace all the 16s with a variable and expand the alphabet to Z.

You can write a check minimum base function and pass A, B and Z/R into it then run a loop checking to see if A + B = Z and A x B = R with the current base, if not then check the next. If you hit the maximum allowable base then return 0. If you find a base that works then run it to the end to see if it is unique or not.

If you cannot figure this out now then you are hopeless!

sfuo 111 Practically a Master Poster

By the way 120 can be of any base from 3 to inf.

Thats exactly what hes getting at. If you want to convert A2C3 you have to say what base it is in because this could be anything from base 13 to infinity the way you see it.

If you are assuming that A2C3 is in hex then you can loop through the string, converting each hex char to decimal and then add it to an integer variable.

#include <iostream>
#include <cmath>
using namespace std;

int hex2dec(string hexstr)
{
    int decval = 0;

    for( unsigned int i = 0; i < hexstr.size(); i++ )
        if( hexstr[i] >= '1' && hexstr[i] <= '9' )
            decval += (hexstr[i] - '0')*pow(16, hexstr.size()-1-i);
        else if( toupper(hexstr[i]) >= 'A' && toupper(hexstr[i]) <= 'F' )
            decval += (toupper(hexstr[i]) - 'A' + 10)*pow(16, hexstr.size()-1-i);

    return decval;
}

int main()
{
    int num = 0xA2C3;
    cout << num << endl;
    cout << hex2dec("A2C3") << endl;

    cin.get();
    return 0;
}
sfuo 111 Practically a Master Poster

I think the biggest problem you are having is that the matrix you think you have is not the one you set up. As you can see I printed out the contents of the matrix and it is correct because I am adding the values of what row and column the for() loops are on.

I also see that you are kind of accessing the matrix with the x and y values being backwards. If you think about it rows are on the y axis and columns are on the x axis. For this example it will not matter since this matrix is <insert special name that I learned in linear algebra here>, which means that it is mirrored about the diagonal.

If you are going to use the new operator then you will have to store the resulting value that you are at in the matrix to a variable that you will return and then delete the memory allocated for the matrix (otherwise you will have a memory leak).

#include <iostream>
using namespace std;

int boundary2D( int xpos, int ypos, int xstep, int ystep )
{
    const int x = 4, y = 4;
    int matrix[y][x];

    for( int r = 0; r < y; r++ )
        for( int c = 0; c < x; c++ )
            matrix[r][c] = r+c;

    for( int r = 0; r < y; r++ )
    {
        for( int c = 0; c < x; c++ )
            cout << matrix[r][c] << " ";
        cout << …
sfuo 111 Practically a Master Poster

Sounds like a grade 4 word problem.

sfuo 111 Practically a Master Poster

What is the maximum value you are putting into these shorts? Are they signed? If you are not filling the shorts right up, and they aren't signed, then maybe you can get away with packing them all into maybe 12 bits rather than 16 (a short is 2 bytes (16 bits not 8 bits as said above)).

sfuo 111 Practically a Master Poster

From reading the wiki page for Greatest common divisor (GCF) it show to use Euclid's algorithm to find the GCF. The link that shows some pseudocode for using the algorithm is here.

And here is a recursive implementation.

int GCF(int a, int b)
{
    return ( (b == 0) ? a : GCF(b, a%b) );
}
sfuo 111 Practically a Master Poster

Why don't you treat this like two 1D boundary conditions (like the other post that was solved)?

If you create a position structure (just contains two ints or doubles for x and y position) then you can return that rather than creating a 4x4 matrix (which you did not allocate memory for).

I'll give you a chance to attempt this before posting any code to help you out because what you need already exists in the other thread and the rest seems pretty straight forward.

sfuo 111 Practically a Master Poster

Modulos gives the remainder of the two numbers if they were used in division.

Places where I use the mod operator are where I see wrapping. So if I had a problem where I wanted to know what angle a line was making from the center of a cricle, I would probably want it to be from [0-360) and not some larger or smaller angle.

The reason why I used static_cast<int> is because I was just trying to show that it will give an int and not pop out a x.5 (and for some reason you are returning double on your function when you are dealing with ints).

Here are two methods that you can use. One is just a cleaned up version of what you posted (an if with the same condition of the do{}while() can be replaced with just a while()) and a method that uses % for both positive and negative steps.

Cleaned up while() method:

int boundaryWHILE( int pos, int step, int size )
{
    if( step == 0 )
        return pos;

    int fpos = pos + step;

    while( fpos < -(size/2) )
        fpos += size;

    while( fpos > (size/2) )
        fpos -= size;

    return fpos;
}

mod method:

int boundaryMOD( int pos, int step, int size )
{
    if( step == 0 )
        return pos;

    step %= size;

    if( step < 0 )
        step += size;

    return (pos + size/2 + step)%size - size/2;
}

The modulus method can probably be …

sfuo 111 Practically a Master Poster

I don't know what this "sth" is and I don't know what assumptions you are making as far as the size coming in goes, but here is a method you could use.

int boundary( int pos, int step, int size )
{
    return (pos + static_cast<int>(size/2) + step)%size - static_cast<int>(size/2);
}

The assumptions that are being made here are that size will be odd and that the range of values will always be equal in both directions off 0. And that step is going to be positive.

sfuo 111 Practically a Master Poster

On line 40 your if statement is assigning not comparing.

You want to use == not just =

Thats all I pick up from just glancing at it, other than the fact that is it "complicated".

sfuo 111 Practically a Master Poster

You can use strings rather than chars.

If you do not want to read in spaces then you can use cin as your method of input. If you want to include spaces (something like a frist and last name) then you need to use getline(cin, str) for input.

sfuo 111 Practically a Master Poster

I would like to say that I agree with WaltP and that you should start off with learning the language before trying to hop into making a game with graphics. The first game I ever made was black jack in a console window (looking back on it, it was a POS) and I learned loads.

However, another option is to use SDL. I learned from it but quickly switched off to OpenGL to attempt some 3D "games".

Here is the tutorial website I used. This shows you how to setup SDL for Code::Blocks and a few other IDEs.

sfuo 111 Practically a Master Poster

When using void functions you don't try to assign them to anything.
Meaning don't do prevScore = scoreChange (prevScore, score);, you would just have to do scoreChange (prevScore, score);.

Since prevScore is being passed by reference (because it is an array) any changes done to it in the function will modify the array from where ever it was called. So after the function call prevScore should hold the value that you are setting all the elements equal to.