home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

ugly c++ problem

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1786
Discussions: 200,958, Posts: 2,379,521, Members: 246,328
Old January 23rd, 2006, 07:10 PM   Digg it!   #1 (permalink)
Member
 
Join Date: Oct 2005
Location: Australia
Posts: 58
ugly c++ problem

I get a compilation error for the last line of the code

"in fuction 'main()' "
"in line 46 '}' expected"
even though i already have the '}' when i add another one it runs the program and
closes quickly (meaning there is an error)
any help would be apreciated!

Code:
 
#include <iostream>
#include <cstdlib>
#include <ctime>
int hitme() {
    int card;
    srand(time(NULL));
    card = rand()%11 + 0;  
    return(card);
    }
using namespace std;
int main() {
    int yc1, yc2, yc3, ytotal, ybank, ybet;
    int cc1, cc2, cc3, ctotal, cbank, cbet; 
    char hors, bet;
    ybank = 25;
    cbank = 25;
    cout<< "Welcome to blackjack!" << '\n' << '\n' << "Your cards are: ";
    yc1 = hitme();
    yc2 = hitme();
    cc1 = hitme();
    cc2 = hitme(); 
    ytotal = yc1 + yc2;
    ctotal = cc1 + cc2;
    cout<< yc1 << " and " << yc2 << " with a total of: " << ytotal;
    while (hors == 'h' || hors == 'H') {
        cout << '\n' << '\n'<< "'H' to hit, 'S' to stay ";
        cin >> hors;
        if (hors != 'h' || hors != 'H'){
        break;
        }
        yc3 = hitme();
        ytotal = ytotal + yc3;
        cout << '\n' << ytotal;
        if (ytotal > 21){
        cout << "BUST!!!";
        break;
        }
    cout<< "Do you want to bet on winning? 'Y' for yes" << '\n';
    cin >> bet;
    if (bet == 'Y' || bet == 'y') 
    cin >> ybet; 
    cout<< '\n' << "You have: " << ybank << " chips. How many would you like to bet? " << '\n';
    ybank = ybank - ybet;
    
    cin.get();
    return 0;
}
oliver w is offline   Reply With Quote
Old January 23rd, 2006, 07:18 PM     #2 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,552
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
You are missing a close brace on your while loop.

As far as it exiting right away your while condition is false when the program starts.
Either convert it to a do while or give hors an intial value.

Not all that ugly When you add another brace and it complies you have a logic error.

Jkrohn
__________________
Signatures blow hard
If your signature contains an ad of any kind, congratulations, you're on my ignore list.
jkrohn is offline   Reply With Quote
Old January 23rd, 2006, 07:30 PM     #3 (permalink)
Member
 
Join Date: Oct 2005
Location: Australia
Posts: 58
OMG!! TY dude
i had been scratching my head chaning things around for about half an hour...
oliver w is offline   Reply With Quote
Old January 23rd, 2006, 09:07 PM     #4 (permalink)
Banned
 
Join Date: Oct 2005
Posts: 752
is that a blackjack prog...EXreaction u got some competiont
towlies high is offline   Reply With Quote
Old January 23rd, 2006, 09:20 PM     #5 (permalink)
SoMuchAnime-SoLittleTime
 
EXreaction's Avatar
 
Join Date: Aug 2003
Location: Plymouth, WI
Posts: 14,983
Blog Entries: 1
Send a message via MSN to EXreaction
Nah, I am finished with mine...Oliver...you should try mine out.
http://www.techimo.com/forum/t161168.html <- source, and exe is in the forum
__________________
My photography: Flickr

Lithium Studios - phpBB3, PHP, and Web Development
EXreaction is offline   Reply With Quote
Old January 24th, 2006, 06:24 AM     #6 (permalink)
Member
 
Join Date: Oct 2005
Location: Australia
Posts: 58
lo im still working on it...
oliver w is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
tv out looks ugly freem Graphics Cards and Displays 12 February 15th, 2004 03:33 PM
ugly money sixf00t4 IMO Community 3 November 30th, 2003 05:52 PM
This could have been ugly! EvilRick Webmastering and Programming 3 September 17th, 2003 05:13 PM
This is getting ugly. :( thunderb0lt Technical Support 8 February 13th, 2003 04:45 AM
Now this one is not just ugly,... Theophylact PC Modification 9 September 22nd, 2002 05:35 AM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2963)
The disrespect of Obama by Russian .. (42)
Making Health Care Worse (178)
Wireless Televisions. (12)
CPU fan stops spinning randomly (9)
Regular Build (11)
windows 7 problem (7)
Laptop with wireless problem. (5)
windows vista security holes (13)
Is the PSU I received dead? (12)
Print spooler problem (15)
radeon x850xt platinum & shader.. (6)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (11)
Recent Discussions
windows vista security holes (13)
Kingston Bluetooth Dongle Driver (1)
Multiple Restarts Required at Boot (3)
Open With ..... Win7 (1)
webcam (0)
upgrade for hp a6101 (0)
Laptop with wireless problem. (5)
Modern Warfare 2: Who Bought It? (64)
tv not turn on-makes clicking sound (2)
CPU fan stops spinning randomly (9)
EVGA 9800 gtx help with finding a goo.. (11)
Regular Build (11)
Help with onclick and buttons (0)
Virus advise (8)
My monitor won't turn on after instal.. (1)
Internet Lost (3)
Dept. of HS: NSA 'Helped' Develop Vis.. (16)
Point and Shoot Camera Suggestions. (4)
Ideal cheap graph card for PC-Gaming? (18)
radeon x850xt platinum & shader 3 (6)
Graphics Card Upgrade Question (4)
For Sale BFG GTX285 OC2 with 10 year .. (3)
How to convert MP3's (4)
Wireless Televisions. (12)
Hp Artist Edition + Matching Bag (0)


All times are GMT -4. The time now is 09:06 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28