Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-2008, 09:05 AM
Uninverted Uninverted is offline
Newbie
 
Join Date: Dec 2007
Posts: 11
Rep Power: 0
Uninverted is on a distinguished road
Default Tic-tac-toe game behaving oddly

I'm trying to make a tic-tac-toe game. Just about everything else works ok, except a little function I wrote to write the board. Does anyone see a problem with this?

C++ Code:
  1. void printboard()
  2. {
  3. char tl, tm, tr, ml, mm, mr, bl, bm, br = 16;
  4. cout << "_","_|_","_|_","_\n";
  5. cout << "_","_|_","_|_","_\n";
  6. cout << " "," | "," | "," \n";
  7. }
__________________
My other car return the first item in a list.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 01-23-2008, 09:16 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

When you're creating a thread, watch out not to double-post. I just deleted the other thread.

Try not to "split" the string up using the comma-operator. Use the bitwise shift left-operator instead. Furthermore, instead of \n's, you can use endls.
Code:
void printboard()
{
    char tl, tm, tr, ml, mm, mr, bl, bm, br = 16;
    cout << "_" << "_|_" << "_|_" << "_" << endl;
    cout << "_" << "_|_" << "_|_" << endl;
    cout << " " << " | " << " | " << endl;
}
Why are you creating all those local variables? You're not even using them. Another thing; you don't have to split it with the bitwise shift left-operator, you can simply just remove them, and have a whole string, instead of lots of small ones.
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-23-2008, 09:24 AM
Uninverted Uninverted is offline
Newbie
 
Join Date: Dec 2007
Posts: 11
Rep Power: 0
Uninverted is on a distinguished road
Default

It's a long story about the variables.

Thanks for the help. I'm honestly not that familiar with C++, but it's the only compiled language I know, and I needed an executable.
__________________
My other car return the first item in a list.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-23-2008, 09:27 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

Hehe, okay.

I hope you solved your problem.
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XBox 360 XNA Game Programming Jordan C# Programming 45 10-29-2008 02:08 PM
Creating a card game (multiplaye online with AI).. what do I program this in? anothersoldier General Programming 1 07-19-2007 07:46 AM
Paying for Links Chan Marketing 26 05-02-2007 09:37 PM


All times are GMT -5. The time now is 10:52 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 101%


Complete - Celebrate!

Ads