Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 9th, 2006, 8:13 PM   #1
jokr004
Newbie
 
Join Date: Jan 2006
Posts: 10
Rep Power: 0 jokr004 is on a distinguished road
Simple blackjack script problem. Need help.

Ok, I'm having trouble with this code. The last '}' token before it goes into the last cout statment, basicly the very end, gets highlighted and I get an "expected declaration before '}' token" error when I try to compile.
Code
Anyone see the problem?
jokr004 is offline   Reply With Quote
Old Feb 9th, 2006, 9:14 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Who in the hell wants to inspect THAT closely! I recommend an editor with brace matching.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Feb 9th, 2006, 9:41 PM   #3
Cache
Hobbyist
 
Join Date: Sep 2005
Posts: 261
Rep Power: 4 Cache is on a distinguished road
My personal suggestion would be to scrap the whole thing, learn about functions, arrays, maybe even classes, and use a 'switch' control structure instead of hundreds of 'if' statements.

Also, if you really must create that many variables without using an array, you could refine your variable declaration/initialization process.

Instead of typing something like:
int a2h;
int a3h;
int a4h;
int a5h;
int a6h;
a2h = 0;
a3h = 0;
a4h = 0;
a5h = 0;
a6h = 0;

I believe it would be preferable to use:
int a2h = 0, a3h = 0, a4h = 0, a5h = 0, a6h = 0;
Cache is offline   Reply With Quote
Old Feb 9th, 2006, 10:02 PM   #4
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 376
Rep Power: 0 King is an unknown quantity at this point
i agree with Cache... learn about arrays or vectors, you could do the same thing with about 1/3 of the code
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Old Feb 10th, 2006, 10:48 AM   #5
jokr004
Newbie
 
Join Date: Jan 2006
Posts: 10
Rep Power: 0 jokr004 is on a distinguished road
ok, I figured out the, I added two extra braces at the end, but now when i compile, it will only run half way throught the program. Thanks for the advice with the variables, very new with c++. And one of the reasons I did it the way I did was because I could copy and paste the set of one variables and easily make the one letter change in the variables by just going down with the arrow key. was a lot faster.
jokr004 is offline   Reply With Quote
Old Feb 10th, 2006, 11:35 AM   #6
Cache
Hobbyist
 
Join Date: Sep 2005
Posts: 261
Rep Power: 4 Cache is on a distinguished road
Quote:
Originally Posted by jokr004
And one of the reasons I did it the way I did was because I could copy and paste the set of one variables and easily make the one letter change in the variables by just going down with the arrow key. was a lot faster.
A lot faster than what? certainly no faster than the time it takes to type an array: int Harts[13];
Cache is offline   Reply With Quote
Old Feb 10th, 2006, 11:44 AM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Any time you look at code and it looks like that, you know you've missed out on something basic. Loops, arrays, functions, function pointers, etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc., etc.,.

Oops, I mean,
for (int i = 0; i < 47; i++) cout << "etc.,";
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:28 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC