![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2006
Posts: 10
Rep Power: 0
![]() |
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? |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#3 |
|
Hobbyist
Join Date: Sep 2005
Posts: 261
Rep Power: 4
![]() |
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; |
|
|
|
|
|
#4 |
|
Professional Programmer
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 376
Rep Power: 0
![]() |
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! |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jan 2006
Posts: 10
Rep Power: 0
![]() |
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.
|
|
|
|
|
|
#6 | |
|
Hobbyist
Join Date: Sep 2005
Posts: 261
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#7 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|