I am having some problems with solving this game. any ideas
#include <iostream>

int main()
{
	char a = ' ', b = ' ', c = ' ', 
		 d = ' ', e= ' ' , f = ' ',
		 g = ' ', h = ' ', i = ' ';
	std::cout << " Tic - Tac - Toe " << std::endl;

	std::cout << a << "|" << b << "|" << c << std::endl
	              << "-+-+-" << std::endl
                              << d << "|" << e << "|" << f << std::endl
	               << "-+-+-" << std::endl
	               << g << "|" << h << "|" << i << std::endl;

{
	bool xWinRow0 = ('X' == a && a == b && b == c); 
	bool xWinRow1 = ('X' == d && d == e && e == f); 
	bool xWinRow2 = ('X' == g && g == h && h == i); 
	bool xWinCol0 = ('X' == a && a == d && d == g);
	bool xWinCol1 = ('X' == b && b == e && e == h);
	bool xWinCol2 = ('X' == a && a == d && d == g); 
	bool xWinDia0 = ('X' == a && a == e && e == i); 
	bool xWinDia1 = ('X' == c && c == e && e == g); 

	bool xWin = (xWinRow0 || xWinRow1 || xWinRow2 
		|| xWinCol0 || xWinCol1 || xWinCol2 
		|| xWinDia0 || xWinDia1); 
	std::cout << " X Wins!. Thanks for playing. " << std::endl;
}

{
	bool oWinRow0 = ('O' == a && a == b && b == c); 
	bool oWinRow1 = ('O' == d && d == e && e == f); 
	bool oWinRow2 = ('O' == g && g == h && h == i); 
	bool oWinCol0 = ('O' == a && a == d && d == g);
	bool oWinCol1 = ('O' == b && b == e && e == h);
	bool oWinCol2 = ('O' == a && a == d && d == g); 
	bool oWinDia0 = ('O' == a && a == e && e == i); 
	bool oWinDia1 = ('O' == c && c == e && e == g); 

	bool oWin = (oWinRow0 || oWinRow1 || oWinRow2 
		|| oWinCol0 || oWinCol1 || oWinCol2 
		|| oWinDia0 || oWinDia1);
	std::cout << "O wins. Thanks for playing." << std::endl;
}
{
	bool allTaken = ( a != ' ' && b != ' ' &&  c != ' '
		        && d != ' ' && e != ' ' && f != ' ' 
		        && g != ' ' && h != ' ' && i != ' '); 
	std::cout << "We have a tie" << std::endl;
}
	// prompt player for location
	char turn = ' ';
	char location = ' '; 
	std::cout << "player  " << turn
		<< ": Please enter location (a, b, c, d, e, f, g, h, i): "; 
	std::cin >> location; 
	
	std::cout << "turn : " << turn << std::endl;


	return 0; 
}

What problems are you having? Also, if you copy your code and paste them within code tags:

[code=cplusplus] // your code pasted here

[/code]
or

[code]

// your code pasted here

[/code]

it is easier to read.

What problems are you having? Also, if you copy your code and paste them within code tags:

[code=cplusplus] // your code pasted here

[/code]
or

[code]

// your code pasted here

[/code]

it is easier to read.

When i run the program it really doesn't do anything there are no error's
but it does not work the way I thought it would.
I can not enter any input .
I think I am going to have to start over

#include <iostream>

int main()
{
    char a = ' ', b = ' ', c = ' ', d = ' ', e = ' ', f = ' ', g = ' ', h = ' ',
        i = ' ';
    std::cout << " Tic - Tac - Toe " << std::endl;

    std::cout << a << "|" << b << "|" << c << std::endl << "-+-+-" << std::endl
        << d << "|" << e << "|" << f << std::endl << "-+-+-" << std::endl << g
        << "|" << h << "|" << i << std::endl;

    {
        bool xWinRow0 = ('X' == a && a == b && b == c);
        bool xWinRow1 = ('X' == d && d == e && e == f);
        bool xWinRow2 = ('X' == g && g == h && h == i);
        bool xWinCol0 = ('X' == a && a == d && d == g);
        bool xWinCol1 = ('X' == b && b == e && e == h);
        bool xWinCol2 = ('X' == a && a == d && d == g);
        bool xWinDia0 = ('X' == a && a == e && e == i);
        bool xWinDia1 = ('X' == c && c == e && e == g);

        bool xWin = (xWinRow0 || xWinRow1 || xWinRow2 || xWinCol0 || xWinCol1 
            || xWinCol2 || xWinDia0 || xWinDia1);
        std::cout << " X Wins!. Thanks for playing. " << std::endl;
    }

    {
        bool oWinRow0 = ('O' == a && a == b && b == c);
        bool oWinRow1 = ('O' == d && d == e && e == f);
        bool oWinRow2 = ('O' == g && g == h && h == i);
        bool oWinCol0 = ('O' == a && a == d && d == g);
        bool oWinCol1 = ('O' == b && b == e && e == h);
        bool oWinCol2 = ('O' == a && a == d && d == g);
        bool oWinDia0 = ('O' == a && a == e && e == i);
        bool oWinDia1 = ('O' == c && c == e && e == g);

        bool oWin = (oWinRow0 || oWinRow1 || oWinRow2 || oWinCol0 || oWinCol1 
            || oWinCol2 || oWinDia0 || oWinDia1);
        std::cout << "O wins. Thanks for playing." << std::endl;
    }
    {
        bool allTaken = (a != ' ' && b != ' ' && c != ' ' && d != ' ' && e != '
            ' && f != ' ' && g != ' ' && h != ' ' && i != ' ');
        std::cout << "We have a tie" << std::endl;
    }
    // prompt player for location
    char turn = ' ';
    char location = ' ';
    std::cout << "player " << turn << 
        ": Please enter location (a, b, c, d, e, f, g, h, i): ";
    std::cin >> location;

    std::cout << "turn : " << turn << std::endl;


    return 0;
}

You have several blocks of code with brackets, but no loops. I imagine you want a loop, so everything goes through the loop once every time the user enters something. Are you sure the program does not take any input or is it possible that it takes input, then immediately ends afterwards? Are you running this through an IDE like Dev C++ or at the command line?

#include <iostream>

int main()
{
    char a = ' ', b = ' ', c = ' ', d = ' ', e = ' ', f = ' ', g = ' ', h = ' ',
        i = ' ';
    std::cout << " Tic - Tac - Toe " << std::endl;

    std::cout << a << "|" << b << "|" << c << std::endl << "-+-+-" << std::endl
        << d << "|" << e << "|" << f << std::endl << "-+-+-" << std::endl << g
        << "|" << h << "|" << i << std::endl;

    {
        bool xWinRow0 = ('X' == a && a == b && b == c);
        bool xWinRow1 = ('X' == d && d == e && e == f);
        bool xWinRow2 = ('X' == g && g == h && h == i);
        bool xWinCol0 = ('X' == a && a == d && d == g);
        bool xWinCol1 = ('X' == b && b == e && e == h);
        bool xWinCol2 = ('X' == a && a == d && d == g);
        bool xWinDia0 = ('X' == a && a == e && e == i);
        bool xWinDia1 = ('X' == c && c == e && e == g);

        bool xWin = (xWinRow0 || xWinRow1 || xWinRow2 || xWinCol0 || xWinCol1 
            || xWinCol2 || xWinDia0 || xWinDia1);
        std::cout << " X Wins!. Thanks for playing. " << std::endl;
    }

    {
        bool oWinRow0 = ('O' == a && a == b && b == c);
        bool oWinRow1 = ('O' == d && d == e && e == f);
        bool oWinRow2 = ('O' == g && g == h && h == i);
        bool oWinCol0 = ('O' == a && a == d && d == g);
        bool oWinCol1 = ('O' == b && b == e && e == h);
        bool oWinCol2 = ('O' == a && a == d && d == g);
        bool oWinDia0 = ('O' == a && a == e && e == i);
        bool oWinDia1 = ('O' == c && c == e && e == g);

        bool oWin = (oWinRow0 || oWinRow1 || oWinRow2 || oWinCol0 || oWinCol1 
            || oWinCol2 || oWinDia0 || oWinDia1);
        std::cout << "O wins. Thanks for playing." << std::endl;
    }
    {
        bool allTaken = (a != ' ' && b != ' ' && c != ' ' && d != ' ' && e != '
            ' && f != ' ' && g != ' ' && h != ' ' && i != ' ');
        std::cout << "We have a tie" << std::endl;
    }
    // prompt player for location
    char turn = ' ';
    char location = ' ';
    std::cout << "player " << turn << 
        ": Please enter location (a, b, c, d, e, f, g, h, i): ";
    std::cin >> location;

    std::cout << "turn : " << turn << std::endl;


    return 0;
}

You have several blocks of code with brackets, but no loops. I imagine you want a loop, so everything goes through the loop once every time the user enters something. Are you sure the program does not take any input or is it possible that it takes input, then immediately ends afterwards? Are you running this through an IDE like Dev C++ or at the command line?

Yes it ends immediately after it begins to run. I am working on visual studio. I just started it so i will give it some more work. Thank you for your time though

Yes it ends immediately after it begins to run. I am working on visual studio. I just started it so i will give it some more work. Thank you for your time though

In Visual C++, if you do "Build Solution" under the "Build" menu, then run it with "Start Without Debugging", Visual Studio will hold the execution window open for you. You can also do "Start Debugging" and put a break point before "return 0". That will also hold the window open. Also, check out this link on a way to do it without Visual Studio doing it for you.
http://www.dreamincode.net/forums/showtopic30581.htm

This sounds like a Dr. Liow problem

What if the location was already taken by X and a player enters O into that very spot. You have no code protecting that. Also Where is your code to tell the players whos turn it is.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.