Sponsored Content
Full Discussion: C++ Help
Top Forums Programming C++ Help Post 302273438 by RossMc on Sunday 4th of January 2009 09:33:14 PM
Old 01-04-2009
C++ Help

Hi i need a bit of help here.

I am creating a connect 4 programme in c++. The programme runs ok but when the programme asks what cell i want to put the X in and i enter a cell referance the X doesn't go in the cell like it should

I was just wondering if anyone would be able to have a look at the code and tell me what wrong

The Code is

Code:
#include <iostream>
 
#include <cstdlib>
 
#include <cstdio>
 
#include <limits>
 
 
 
using std::cout;
 
using std::cin;
 
using std::endl;
 
int main()
 
{
 
 
 
char a[] = {'|','_','|','_','|','_','|','_','|','_','|','_','|','_','|'};
 
char b[] = {'|','1','|','2','|','3','|','4','|','5','|','6','|','7','|'};
 
char board[6][7];
 
int i, j, k =0;
 
int row;
 
int column;
 
int game =1;
 
 
for (i=0; i<6; i  )
 
for (j=0; j<7; j  )
 
board[i][j] = ' ';
 
cout<<" ";
 
for( j = 0; j<15; j  )
 
cout <<b[j];
 
cout <<endl;
 
for ( i=0; i<6; i  )
 
{ cout <<i 1;
 
for( j = 0; j<15; j  )
 
cout <<a[j];
 
cout <<endl;
 
}
 
while(game ==1)
 
{
 
cout << "Player 1 Your Turn Please Enter Which Cell You Would Like" << endl;
 
cin >> row >> column;
}
 
if(board[row-1][column-1] ==' ')
 
board[row-1][column-1] = 'X'; }
 
// game over

Here is a programme of what the programme actually does

Image

Thanks Ross
 
wml::std::all(3)						     EN Tools							  wml::std::all(3)

NAME
wml::std:all - All of Standard (STD) category SYNOPSIS
#use wml::std::all DESCRIPTION
This includes all existing include files of the Standard (STD) category, i.e. all includes with prefix wml::std. The following files currently exist: wml::std::box(3) ... Easily Create Rectangular Box wml::std::case(3) ... Convert Tags to Upper or Lower Case wml::std::grid(3) ... Layout Grid wml::std::href(3) ... Enhanced Hyperlink wml::std::info(3) ... Page Information wml::std::lang(3) ... Multi-Lingual Support wml::std::label(3)... Labels and References wml::std::logo(3) ... Logo Insertion wml::std::page(3) ... Standard HTML Page Header and Footer wml::std::tags(3) ... Standard Support Tags wml::std::toc(3) ... Table of Contents Generation AUTHOR
Ralf S. Engelschall rse@engelschall.com www.engelschall.com REQUIRES
Internal: P1 External: -- SEE ALSO
wml::std::box(3), wml::std::case(3), wml::std::grid(3), wml::std::href(3), wml::std::info(3), wml::std::label(3), wml::std::lang(3), wml::std::logo(3), wml::std::page(3), wml::std::tags(3), wml::std::toc(3). EN Tools 2014-04-16 wml::std::all(3)
All times are GMT -4. The time now is 05:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy