C++ :: Board Not Printing Correctly
Jul 19, 2013
I'm writing a version of the classic Snake game. However, my board is not printing correctly. The right hand border is in the incorrect location. Also, when I randomly generate where the food ('X') is located, it only generates on the edges of the boundaries.
#include <iostream>
#include <cstdlib>
using namespace std;
const int ROWS = 21;
constint COLS = 61;
[code].....
View 5 Replies
ADVERTISEMENT
Jun 2, 2013
I have a procedure that prints the fields of ethernet frames and ip headers. I have an issue with the src mac addr being printed incorrectly and incompletely. The part in red is the trouble code.
Code:
1#include "sniffer.h"
2
3void print_headers(struct ethhdr * ethhdr, struct ip * iphdr){
4
5 char ipstr_src[INET_ADDRSTRLEN];
6 char ipstr_dst[INET_ADDRSTRLEN];
7 char macstr_dst[ETH_ALEN], macstr_src[ETH_ALEN];
[Code] ....
View 2 Replies
View Related
Feb 7, 2014
I'm programming tic tac toe but the board is not showing numbers, and it is simply stating the winner without any input: (the win conditions are not complete, but it shouldn't matter).
#include <iostream>
#include<string>
using namespace std;
//Write a two-player tic-tac-toe game; use enums when possible to represent the values of the board
char ticBoard[3][3];
char board[10];
void showBoard();
bool moveIsValid(int m);
int whoWon(); // 0 tied, 1 p1, 2 p.2
[Code] ....
View 6 Replies
View Related
Mar 14, 2013
void(..)
bool(..)
Direct to the board[8][8].
View 7 Replies
View Related
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
Feb 22, 2015
Im trying to make a Tic Tac Toe board for an assignment. Right now it compiles fine but when I enter an x or o it does not update the board it just prints out the '.'s that the board is initialized to. Also, when I get to player 2 the board will printout twice so its 6 rows or 3 columns. The project uses a main to ask who starts then goes to a play function that asks for inputs and calls the makeMove function to place the x's and o's and the print function to display the updated board.
bool Board::makeMove(int rowIn, int columnIn, char currentPlayer) {
if (playBoard[rowIn][columnIn] == '.') {
playBoard[rowIn][columnIn] = currentPlayer;
return true;
[Code] ....
View 14 Replies
View Related
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
Mar 7, 2013
Okay so this is part of a small uni module around the arduino board. The task is to simulate traffic lights at a junction. At the moment my code below runs through the sequence with 2 seperate lights. When one set of lights turns RED , the other turns GREEN.In my main loop method I need to add a button for a crossing. I want to be able to check if the button is pressed at each of the delays but do not want to have to hold it down.I have thought about putting it at the top of the loop but then the program will only check if button is pressed in that point therefore the user will have to hold it down?
Code:
int green1 = 13 ;
int amber1 = 12 ;
int red1 = 11 ;
int green2 = 6 ;
int amber2 = 7 ;
int red2 = 8 ;
}
[code]....
View 5 Replies
View Related
May 25, 2014
How to reset the board in order to play again without spots already taken.
#include <iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
char location[10] = {'0','1','2','3','4','5','6','7','8','9'};
int displayMenu(int &player, int &win);
[Code] .....
View 1 Replies
View Related
Sep 13, 2014
/* This is what I have so far what i am trying to do is to initialize the arrays at zero and output the board to the screen. Part of the problem is the user has the option of the board size. All this is suppose to do is to output the board to the screen. I am having problems understanding 2D Arrays.
*/
using namespace std;
int main() {
const int BOARD_MAX = 10; // Maxinum Board size.
const int BOARD_MIN = 3; // Minimum Board size.
array = [COL];
array [ROW];
[Code] ....
View 5 Replies
View Related
Apr 2, 2014
I am working on my senior project and my currect task is to make a menu. I dont know what the best way to do it. my code is not complete and i am completely lost. code found below:
Code:
#include <hidef.h> /* common defines and macros */#include "derivative.h" /* derivative-specific definitions */
#include "lcd.h"
#include<menu.h>
void main(void) {
char *msg1 = "Menu";
[code].....
View 4 Replies
View Related
Oct 15, 2013
Assignment on making a program like candy crush but it is called as number crush.
View 3 Replies
View Related
Apr 2, 2013
Every time the timer clicks it should show a text letter like (T) for tortoise and (H) for hare that moves around the board when the user hits go on the GUI.
View 12 Replies
View Related
Oct 24, 2013
I am required to create a simple candy crush game.
I am this stage where I am required to print the 'box' for navigation purpose at the center of the board once the program initializes.
Here is the code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//FUNCTION: Draw the Board
[Code].....
I understand that the sequence could be to clear the screen and print the whole board with the indicated marker.
*Yes I am required to move the box in later part of the program but for now, I just need to get the box to show up at coordinate
Code: board[5][5]
I am stuck ...
View 11 Replies
View Related
Mar 13, 2013
Is there any standard USB protocol which i can follow to send data to my embedded board(and vice versa). I have no clue on USB programming using c,is there any example code i could follow,
View 4 Replies
View Related
Mar 16, 2013
I've been trying to figure out how to implement a way to save this board state throughout a user's inputted path. At the end, I need the output to print out the board states (user's path) of how he or she got the puzzle solved. This puzzle is the 15 Puzzle; but we have it to change by the user's input on what size they want to play (3x3 to 5x5). How to save the board state of each user input, then print those out in order from beginning to solved puzzle state. Subsequently, I would also need transferring the board state to change with using a vector to store the size based on user input. How to proceed, using a first search to solve the puzzle from the current board's state.
calculations.h
Code:
/*Calculations set as a header to keep compiling simple and faster*/
#ifndef calculations
#define calculations
int solved[5][5];
void initialize(int board[][5], int);
void slide(int board[][5],int move,int);
bool isBoardSolved(int board[][5],int);
[Code] .....
View 6 Replies
View Related
Feb 17, 2015
so i have this problem with my code ( not running)i want to read ( 2 double numbers x,y) and ( one integer z) then calculate reminder of x and y ( after they both converted to integer) and the formula : x^2 + y^2 + z^2and : x^z + y^z
here is what i came up with :
Code:
// compute.c
#include<stdio.h>
#include<math.h>
int main(void)
{
[Code]....
it also says in q : be sure to test the user input to make sure x,y,z are positive . any negative or zero should not be accepted and must print error msg ==> do i have to have an if statement here ? or the while loop is enough ?
View 9 Replies
View Related
Jan 23, 2015
I'm working on a school assignment that asks us to make code calculating the quadratic formula.
Code:
#include <stdio.h>
#include <math.h>
int main(void) {
double a = 0;
double b = 0;
double c = 0;
double discriminant = 0;
double solution = 0;
double solution2= 0;
}
[code]....
View 4 Replies
View Related
Feb 7, 2015
My program isnt averaging correctly.
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;
struct nameGPA {
[Code] .....
View 4 Replies
View Related
Nov 2, 2014
When I try to open the cpp source in Visual Studio, it just opens a blank notepad window. The cpp file says its 4 kb and there was code in it.
View 5 Replies
View Related
Nov 26, 2013
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;
[Code] ....
View 1 Replies
View Related
Mar 10, 2013
Well I have my program running and the Variables are not passing correctly and the return statements are not returning correctly. Here is the parts that are not working.
#include <iostream>
#include "fight.h"
#include <time.h>
#include "player.h"
#include "stdlib.h"
#include <cstdlib>
using namespace std;
combat A;
combat::combat(void)
[Code] ....
View 11 Replies
View Related
Oct 28, 2014
I have an assignment for class .. It works, the do-while loop isn't working correctly. Once I am doing inputting information for any employee It should ask to continue. It doesn't, It skips that loop and prompts to enter the type of employee again.
#include <iostream>
#include <iomanip>
using namespace std;
int main( ) {
char empInput;
char continueResponse;
[code].....
View 3 Replies
View Related
Mar 5, 2015
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
[Code]....
It compiles just fine and it will add new entries and print the entries just fine but when I go to delete an entry it will delete it but it will mess up the one before it.
View 8 Replies
View Related
Dec 14, 2013
I am writing a program that manages a group of tool bins. This group is handled as an object that is an array of two element structures called InvBin. I initialize the bins with data from a file which contains the descriptions and initial quantities. I also have functions to add or subtract items from a bin and a function to display a report of the description and quantity of all of the bins.
The add and remove functions work correctly based on the cout statement in the functions, however when I display the report, it displays the initial quantity instead of the new quantity. In addition, when I use the add and remove functions again on the same bin, they use the initial quantity.
These are the add and remove functions and the report function from the main program.
Code:
//Adds an item to a bin
void addItem(HANDLE screen, BinManager tools, int &count) {
int binNum;
int addNum;
system("cls");
[Code].....
View 2 Replies
View Related
Jul 24, 2013
I've been working on this program to create a simple desk calculator for a school assignment, and I managed to finish. All we had to do was add, subtract, multiply, and divide positive integers - and I was able to do that just fine. This program got me thinking though, because I do not know how to write commands to multiply/divide negative numbers.
In fact, when I divide a number like 21 by 4, it comes out to 5 because I don't know how to allow it to compute remainders (which wasn't a requirement for my program). This intrigued me so I've been trying to figure it out for the last few days but to no avail. Here's my code:
Code: void flush_buffer(){
int ch;
while ((ch = getchar()) != '
' && ch != EOF);
[Code]....
And just know that my code works perfectly fine, I'm not here for troubleshooting it. I just want to know what I can change to allow negative values to be correctly computed.
View 12 Replies
View Related