Thread: ugly c++ problem
-
January 23rd, 2006, 07:10 PM #1Member
- 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; }
-
January 23rd, 2006, 07:18 PM #2
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.
JkrohnSignatures blow hard
If your signature contains an ad of any kind, congratulations, you're on my ignore list.
-
January 23rd, 2006, 07:30 PM #3Member
- 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...
-
January 23rd, 2006, 09:07 PM #4Banned
- Join Date
- Oct 2005
- Posts
- 752
is that a blackjack prog...EXreaction u got some competiont
-
January 23rd, 2006, 09:20 PM #5
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
-
January 24th, 2006, 06:24 AM #6Member
- 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
-
tv out looks ugly
By freem in forum Graphics Cards and DisplaysReplies: 12Last Post: February 15th, 2004, 03:33 PM -
ugly money
By sixf00t4 in forum IMO CommunityReplies: 3Last Post: November 30th, 2003, 05:52 PM -
This could have been ugly!
By EvilRick in forum Webmastering and ProgrammingReplies: 3Last Post: September 17th, 2003, 04:13 PM -
This is getting ugly. :(
By thunderb0lt in forum Technical SupportReplies: 8Last Post: February 13th, 2003, 04:45 AM -
Now this one is not just ugly,...
By Theophylact in forum PC ModificationReplies: 9Last Post: September 22nd, 2002, 04:35 AM



LinkBack URL
About LinkBacks



Reply With Quote



hey! That's my setup! I always intended....
Is It Just Me? v233893843