C++ :: Checkers Game - Expected A Statement Error

Dec 4, 2013

im making a checkers game but i keep getting a 'expected a statement' error on the first 2 'else's

void Initialise(){
for(int row=0; row<3; row++) {
if(int row=0<3)
//player 1 pieces
string player = "Player 1";
for(int col=0; col<8; col++)

[code]....

View 4 Replies


ADVERTISEMENT

C :: Force Move In Checkers Game

Dec 6, 2013

I am doing a checkers program in C and were not allowed to use standard C99. Things are going relatively well so far. I have 2d array that acts as a matrix for my board and have ways to check if a space is empty and if it is occupied by a specific players chip.

Right now I have a giant messy method that I will split up sooner or later but Im just trying to understand and build the logic. It looks like this:

Code:
void isValidMove(int origin, int dest, int player) {
int rowDiff = abs(origin%8 - dest%8);
int possibleMoveLeftUp = origin - 9;
int possibleMoveLeftDown = origin + 9;
int possibleMoveRightUp = origin - 7;

[Code] ....

So although its not pretty i think the logic is sound. I can tell whether or not a player is attempting to make a move or a jump. I haven't implemented make_move() yet but thats no problems. My biggest deal is that I need to find a way to tell the user he has to jump if its available. I feel like this is a very difficult task for me to grasp and is more about algorithm logic and math then the C language which is what the course is for.

So, how I could loop through all of a specific players chips and see if that player has an available jump. Also if he does then the jump has to be taken and then checked again as if there is another legal jump then it needs to be taken as well until their are no jumps left. Of course there could be 2 routes available, but I think I could deal with that if I just could come up with a reasonable way of checking....

View 2 Replies View Related

C/C++ :: Trying To Draw A Grid In A Square For Simple Checkers Game

Oct 7, 2014

I am trying to draw a grid for checkers. I could draw a square at the starting point from origin with the code below(attached the pic below how it looks) however I am not being able to draw a grid when the program runs.

#include "ccc_win.h"
// GameDemo.cpp
// Shows how to place a piece accurately on a grid after a mouse click.
#include "ccc_win.h" // for graphics classes and functions
using namespace std;
int ccc_win_main(void) // main function for graphics program

[Code] ....

View 3 Replies View Related

C++ :: Error - Expected Unqualified ID

Dec 2, 2014

I can't figure out this error.

#include <iostream>
using namespace std;
bool isPrime(int number); {
primeNumber = isPrime(number);

[Code] ....

View 2 Replies View Related

C/C++ :: Error / Expected Initializer Before String

Nov 15, 2014

I'm working on a school project learning C++. I'm running into an error I can't seem to find the answer for (see topic title).

main.cpp
#include <iostream>
#include <string>
#include "Signature.h"
#include "Genome.h"
using namespace std;
// Calling Function
int main() {
Signature Sig1; // Create Signature object
Genome gString1; // Create Genome object

[code]....

View 1 Replies View Related

C/C++ :: Error - Expected Unqualified-id At End Of Input?

Apr 3, 2014

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
using namespace std;
class CV {
    public:
    char name; 
    char qualfctn;

[Code]....

View 1 Replies View Related

C :: Stack Overflow - Expected Expression Error

Sep 10, 2013

I'm pretty new to C, and keep getting an error. Basically I'm trying to convert a ppm image to all red. Here is my code that I can't get to work:

Code:
change(pixel_t *PIXEL, &w, &h,pixel_t *buffer);

And here is the beginning of my convert function:

Code:
void change(pixel_t *pixel, int w, int h, pixel_t *buffer) {

int average, sum;
int i;
pixel_t *pointer;

Everything else works fine. I keep getting an error when I call the convert function. It says "expected expression before pixel_t" and "too few arguments to function "change". I know that everything else in the main is working.

View 3 Replies View Related

C/C++ :: Expected Outcome Error On X Amount Of Rolls

Feb 20, 2015

I have a program that rolls two dice however many times the user specifies and counts the occurrences of each total (2-12). I have to compare the results of the random rolls to the expected outcome and give the percentage of error between the two.

I have an example that tells me the sum to expected outcome are as follows if I roll 36 times: 2/1, 3/2, 4/3, 5/4, 6/5, 7/6, 8/5, 9/4, 10/3, 11/2, 12/1 but I don't know how to put that into code to get the expected outcome for X amount of rolls.

View 11 Replies View Related

C/C++ :: Error Thrown By Compiler / Identifier Expected And Declaration Terminated Incorrectly

Jan 30, 2015

Error message is identifier expected and declaration terminated incorrectly.

//to define a class Employee
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<conio.h>
class cEmp {

[code]....

View 7 Replies View Related

C++ :: Tic Tac Toe Console Game - If Statement Does Not Make Correct Decision

Feb 18, 2015

I recently wrote a "Tic Tac Toe" console game, and i seem to have a problem in my winning conditions, as when it checks if the player won (should have won) it doesn't take the appropriate action.

The winning conditions are in CoreLogic.cpp

here's the code, might not be the most pretty and clean code ever but it works for me.

there are more files i just didn't feel the need to include them all since the problem is only within CoreLogic.cpp and possibly in main.cpp

pos1-pos9 have been declared in the UserInterface.cpp and are being used to determine the correct decision to do within CoreLogic.cpp

Nothing happens when you win at this point it just exits the program.

View 19 Replies View Related

C++ :: Getting Error Using Enum In If Statement?

Jan 19, 2014

I'm trying to make a simple C++ program in which the user must try to guess a number, if they guess too high it says "too high" and if they guess too low it says "too low".

I also decided to add a feature which allows them to select how many tries they would like to guess the number. I tried to make "tries" type an enum so if the user could not pick an invalid number but for some reason i cannot use it in an if statement.

here is the code and i am getting the first error on line 27:

Code:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int guess;

[Code]....

View 7 Replies View Related

C :: Error When Compiling WHILE Statement

Mar 6, 2013

Code:
/* Demonstrates using the gets() return value. */
#include <stdio.h>
/* Declare a character array to hold input, and a pointer. */
char input[257], *ptr;

[Code]....

I just got this from the book that I am using and it is for testing for input of a blank line and readers are being warned in using this format (line 18):

Code: while ( (*ptr = gets(input)) != NULL)

What is the correct syntax if a gcc compiler is to be used?

View 8 Replies View Related

C++ :: Syntax Error If Statement

Feb 19, 2012

I got syntax error in if statement ,, i checked the line i put { after the condition don't know where the mistake are

1>c:usershani est11 est11code.cpp(20) : error C2143: syntax error : missing ';' before 'if'

PHP Code:

# include <iostream>
using namespace std;
int seqsearch (int list[],int length,int key);
void main () {
    int marks [30];

[Code] ....

View 2 Replies View Related

C++ :: Switch Statement - Error At Output

Jul 26, 2012

I have a question related to switch statement, which the switch in class employee2 gives me error at output. Program compiled well. I am using Code::Block Compiler V10.5. I have created object of class employee2 in main() function to get data from user, store it and display it. At the output, Compiler doesn't show actual output what i am expecting. The fun thing is my compiler printed emocion like (), where (hourly/monthly/weekly) was supposed to print.

Code:
#include <iostream>
using namespace std;
enum period {hourly,weekly,monthly};
class employee2 {
private :
char ch;
period x;
double compensation;

[Code] ....

View 10 Replies View Related

C++ :: Using Loops For Drawing A Checkers Board?

Jan 27, 2014

This is the text of exercise 4 of chapter 12 of PPP; Draw a checkers board: 8-by-8 alternating white and red squares.

Is there a way to use the loop for doing that code to minimize the size of the code?

View 9 Replies View Related

C++ :: Can't Refresh Checkers Board On Application

Dec 6, 2013

I Cant get my checkers game board to refresh every time i make a move. i have system("cls") But it does nothing of the sort.. To move a pice ive created an illusion which swaps one pieces appearance with another :

void getpiecetomove(int startx,int starty, int endx, int endy) {
boardpiece tmp;
//Regular Moves Pieces
tmp = board[startx][starty];
board[startx][starty] = board[startx+1][starty+1];
board[startx+1][starty+1] = tmp;
system("cls");
}

View 7 Replies View Related

C++ :: Employee Database - Bizarre Error With If Statement

Dec 21, 2014

I have written a program that stores employees in a database object. You can Add, hire, fire, promote, demote, and display employees. The program uses an interface, a database class, and an employee class with member functions.

The strange behavior is in my switch statement in interface.cpp. I have a '#' that represents a command line. Add and Display functions are ok, but if I hire, fire, promote or demote. It will display '##' for the next input. I ran the debugger and after hire/fire/promote/demote is called, the first if-statement goes to 'else' and I'm trying to figure out why.

Note: main() calls mainMenu() to run the program

// interface.cpp
#include <iostream>
#include "database.h"
#include "display.h"
void mainMenu() {
displayMenu();
Database* employeeDatabase = new Database();

[Code] .....

Here are the two classes...

// database.cpp
#include <iostream>
#include <vector>
#include <memory>
#include "employee.h"
#include "database.h"
using namespace std;

[Code] .....

View 6 Replies View Related

C Sharp :: Getting Syntax Error In INSERT INTO Statement

Apr 6, 2012

if (comboBox1.Enabled == true && textBox5.Text != "")
{
OleDbConnection con = new OleDbConnection();
con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" + @"Data Source= c:usersmert" + @"documentsvisual studio 2010ProjectsPayrollCSWindowsFormsApplication7P ayrollDB.accdb";

[Code]....

this is my code. I am getting this error on "cmdole2" query.

error text is:

---------------------------

---------------------------
System.Data.OleDb.OleDbException (0x80040E14): Syntax error in INSERT INTO statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult)

[Code]....

View 1 Replies View Related

C++ :: Logical Error - Change Value Inside Void Statement

Jul 16, 2013

I've encountered a slight logical error in my code

/*
Lab06_pensionplans.cpp
Purpose :
- Create a simple financial application to calculate retirement plans
*/
#include <iostream>
#include <cstdlib>
using namespace std;
void displayMenu() {
system("cls");

[Code] ....

Look at case 2, which the user supposed to key in a new input, the problem is the value will never got into main function, I don't know what should I modify with the function.

Figured out I need to change the

void changeData(int startingAge, int numOfYears,
double lumpSumAmount, double yearlyAmount, double interestRate )

into

void changeData(int &startingAge, int &numOfYears,
double &lumpSumAmount, double &yearlyAmount, double &interestRate )

View 2 Replies View Related

C++ :: Error - Statement Cannot Resolve Address Of Overloaded Function

Nov 2, 2013

I can't seem to figure out whats causing this error: statement cannot resolve address of overloaded function . Error is before line 14 in bubblesortrand function. Thnx in advance.

void bubblesort(int num[], int a_size)
{
int i, j, temp;
for(i = (a_size - 1); i >= 0; i--)

[Code].....

View 4 Replies View Related

C++ :: Allegro Shooter Game Error

Jan 19, 2014

I started making a shooter game where enemies appear randomly and you have to shoot them. Everything works fine except sometimes whenever a bullet hits an enemy an error comes up that says "Expression: vector subscript out of range". It doesn't happen every time there is a collision, which confuses me. Here is the collision of the bullets with enemies.

for (unsigned int i = 0; i < bullets.size(); i++) {
if (bullets[i].type == 1) {
for (unsigned int j = 0; j < enemies.size(); j++) {
float distance = sqrt(pow(bullets[i].x - enemies[j].x, 2) + pow(bullets[i].y - enemies[j].y, 2));
if (distance < bullets[i].radius + enemies[j].radius) {
bullets.erase(bullets.begin() + i);
enemies.erase(enemies.begin() + j);
} } }

View 3 Replies View Related

C++ :: Game Engine - Linking Error On MinGW

Aug 6, 2013

I want to write a game engine with MinGW and Code::blocks ide

[URL] ....

This is my project's source code

[URL] .....

This is the build log.

I can't code it here, because it's two large to add the characters!

View 10 Replies View Related

C++ :: Program To Order Pizza - Empty Controlled Statement Found Error

Aug 25, 2013

I am creating a pizza program for ordering a pizza and I have removed all the errors except for two. I have tried everything I can think of to fix this problem so it will compile, but to no avail. The only errors left are:

1>------ Rebuild All started: Project: Pizza Order App Midterm, Configuration: Debug Win32 ------
1> stdafx.cpp
1> Pizza Order Midterm.cpp
1> Pizza Order App Midterm.cpp
1>c:usersindia-n-jerrydocumentsvisual studio 2010projectspizza order app midtermpizza order app midtermpizza order app midterm.cpp(57): warning C4390: ';' : empty controlled statement found; is this the intent?

[Code] ....

The entire code is listed below seperated into 1 header and 2 cpp files.

// OrderPizzaApp.cpp : Defines the entry point for the console application.//

#include "stdafx.h"
#include "Pizza_Order.h"
#include <iostream>
#include <string>
using namespace std;

// prototypes
Pizza_Order createPizza_Order();

[Code] .....

View 5 Replies View Related

C++ :: If Statement Error - Match Text Variable That User Has Entered With Another Got From Array

Dec 3, 2014

I have an if statement that should either match a text variable that the user has entered and a another text variable that has been got from an array but they won't match even if they are the same,Im at a lost with it.

void displayQuestion(int noQuestion, string questionArray[], string answerarray[], string answer, double scorearray, double finalscore){

cout << questionArray[noQuestion] << endl;
cout << "enter an answer " << endl;
cin >> answer;

[Code] ....

View 1 Replies View Related

C :: Random Number Game - Segmentation Fault (core Dumped) Error

Jun 25, 2013

Ok, so doing an assignment for a random number game where you guess and it says too high or too low until you get it right or run out of tries. Here is what I got so far:

Code:
//Cameron Taylor

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int main(){
srand(time(0));
int number = rand()%100+1;;
int guess, numberGuess;

[Code] ....

Getting "Segmentation fault (core dumped)" after inputting the first number, but it compiles correctly.

I later have to add "Do you want to play again (y/n)", so I will use this post to continue that later.

View 13 Replies View Related

C++ :: Game Design Practice For Accessing Container Of Game Objects

Dec 21, 2014

I'm working on my first video game. So far I have a few classes in the game starting with the Game class which includes a list of GameObjects (another class). There are several classes that inherit from GameObjects used to implement things like bullets, explosions, various enemy types, etc.

The game essentially iterates through the list of GameObjects to update/render them. I would like to provide access to the Game's list of GameObjects inside another class (like the Bullet class) so I can put new objects on the list. For example, when a bullet hits, I want to add an explosion to the Game's GameObject list it can be updated/rendered.

How this should be setup? I was considering adding a pointer to the Game or GameObject list to the GameObject class (and methods to access it), but I was wondering if there is a better way to set this up?

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved