+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    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;
    }

  2. #2
    Real gangstas sip on Yacc jkrohn's Avatar
    Join Date
    Oct 2001
    Location
    Suckas-ville
    Posts
    4,554
    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.

  3. #3
    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...

  4. #4
    Banned
    Join Date
    Oct 2005
    Posts
    752
    is that a blackjack prog...EXreaction u got some competiont

  5. #5
    Ultimate Member EXreaction's Avatar
    Join Date
    Aug 2003
    Location
    Madison, WI
    Posts
    15,225
    Blog Entries
    1
    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
    "The problem with quotations on the internet is that the sources are hard to verify" - Abraham Lincoln

  6. #6
    Member
    Join Date
    Oct 2005
    Location
    Australia
    Posts
    58
    lo im still working on it...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

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

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews