View Full Version : Compiling tactactoe
spacerocket
May 23rd, 2014, 05:48 PM
Hello,
I have written a tictactoe game which is located in my home directory and created a folder for it "Tictactoe". Inside "Tictactoe " is main.cpp, tictactoe.cpp and tictactoe.h. How can I create executable program of all these files? If I try to compile tictactoe.cpp alone I get error message.
lisati
May 23rd, 2014, 05:57 PM
How are you currently trying to compile the program? What specific error message are you seeing?
spjackson
May 23rd, 2014, 06:01 PM
Well, assuming those sources comprise a well-formed program, and making lots of other assumptions too...
cd ~/Tictactoe
g++ -o tictactoe main.cpp tictactoe.cpp
spacerocket
May 23rd, 2014, 06:35 PM
Do you mean
g++ -o tictactoe main.cpp tictactoe.cpp tictactoe.h
I have three files there (Inside Tictactoe).
spjackson
May 23rd, 2014, 06:39 PM
No. It would be very unusual to include a header file (.h) in the build command. It will be included by one (or probably both) of the other two modules.
spacerocket
May 23rd, 2014, 08:29 PM
~ Welcome to Connect Four! ~
Make 4 in a row to win!
Press '0' for a computer assisted move
Good luck!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ │ │ │
───┼───┼───┼───┼───┼───
3 │ │ │ │ │
───┼───┼───┼───┼───┼───
4 │ │ │ │ │
───┼───┼───┼───┼───┼───
5 │ │ │ │ │
───┼───┼───┼───┼───┼───
6 │ │ │ │ │
Player 1's turn.
Just taking a random move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ │ │ │
───┼───┼───┼───┼───┼───
3 │ │ │ │ │ 1
───┼───┼───┼───┼───┼───
4 │ │ │ │ │
───┼───┼───┼───┼───┼───
5 │ │ │ │ │
───┼───┼───┼───┼───┼───
6 │ │ │ │ │
Player 2's turn.
Found defensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ │ │ │
───┼───┼───┼───┼───┼───
3 │ │ │ │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ │ │ │
───┼───┼───┼───┼───┼───
5 │ │ │ │ │
───┼───┼───┼───┼───┼───
6 │ │ │ │ │
Player 1's turn.
Found offensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ │ │ │
───┼───┼───┼───┼───┼───
3 │ │ │ │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ │ │ │ 1
───┼───┼───┼───┼───┼───
5 │ │ │ │ │
───┼───┼───┼───┼───┼───
6 │ │ │ │ │
Player 2's turn.
Found defensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ │ │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ │ │ │ 1
───┼───┼───┼───┼───┼───
5 │ │ │ │ │
───┼───┼───┼───┼───┼───
6 │ │ │ │ │
Player 1's turn.
Found offensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ │ │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ │ │ │ 1
───┼───┼───┼───┼───┼───
5 │ │ │ │ │
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 2's turn.
Found defensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ │ │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ │ │ │ 1
───┼───┼───┼───┼───┼───
5 │ │ │ │ │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 1's turn.
Found defensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ │ │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ │ │ │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ │ │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 2's turn.
Found offensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ │ │ │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ │ │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 1's turn.
Found defensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ 1 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ │ │ │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ │ │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 2's turn.
Found offensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ 1 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ │ │ 2 │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ │ │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 1's turn.
Found defensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ 1 │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ 1 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ │ │ 2 │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ │ │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 2's turn.
Found defensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ 1 │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ 1 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ 2 │ │ 2 │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ │ │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 1's turn.
Found offensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ 1 │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ 1 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ 2 │ │ 2 │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ │ 1 │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 2's turn.
Found defensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ 1 │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ 1 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ │ 2 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ │ 1 │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 1's turn.
Found defensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ 1 │ │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ 1 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ 1 │ 2 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ │ 1 │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 2's turn.
Found offensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ │ │
───┼───┼───┼───┼───┼───
2 │ │ 1 │ 2 │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ 1 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ 1 │ 2 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ │ 1 │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 1's turn.
Found defensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ 1 │ │
───┼───┼───┼───┼───┼───
2 │ │ 1 │ 2 │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ 1 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ 1 │ 2 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ │ 1 │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 2's turn.
Found offensive move!
0 │ 1 │ 2 │ 3 │ 4 │ 5
───┼───┼───┼───┼───┼───
1 │ │ │ 1 │ │
───┼───┼───┼───┼───┼───
2 │ │ 1 │ 2 │ │ 2
───┼───┼───┼───┼───┼───
3 │ │ 1 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
4 │ 1 │ 2 │ 2 │ 2 │ 1
───┼───┼───┼───┼───┼───
5 │ │ 1 │ 2 │ 1 │ 2
───┼───┼───┼───┼───┼───
6 │ │ │ │ │ 1
Player 2 wins!
What is this program supposed to do?? I thought I could play against computer. Strange. Maybe this code wasn`t a tic tac toe.
dwhitney67
May 25th, 2014, 12:48 PM
What is this program supposed to do?? I thought I could play against computer. Strange. Maybe this code wasn`t a tic tac toe.
It looks like the popular Connect 4 (http://en.wikipedia.org/wiki/Connect_Four) game. Fortunately for you that the application did not have a call to system() to remove all the files from your user account.
A little advice... for small projects, and for those that are not well known (and possibly not trusted), try to inspect the code before you compile and run it.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.