Ask questions via twitter! Message any question to @answers on twitter. We'll publish the question and send you a reply each time there's a new answer.
Next Question

Answered Question

 
M$1 May 11, 2009 03:06 AM

Error C1004: Unexpected end of file; C++ issues.

Well, at orange's advice, I pasted the code itself here: http://pastebin.com/m12163fff

As my first program, with limited experience, there are probably dozens of things I could do better, and while pointers are greatly welcome, my particular question is WHERE IN THE WORLD AM I MISSING A BRACE!!! I've done some serious searching myself, but everything looks fine to me. I even tried adding 'punctuation' places to see if it helped, but as of right now, I'm stumped and frustrated. If anyone feels like helping me peruse the almost 6000 lines of code, I'd be extremely grateful.
Interesting Question?  Yes (0)   No (0)   
RSS
 
 

Best Answer  Chosen by Asker

 
May 12, 2009 01:36 PM
The problem is that you forget to close the outermost switch statement for each of your nested switch statements:
  1. You have a nested switch statement for days that is nested at most 4 deep for
    randday1, randday2, randday3, and randday4. Before you begin movie genre, you didn't close the outermost switch for days. There should be a closing brace right after the "break" before the switch statement for randmovie1.
  2. Similarly, you don't close the outermost switch for movie genre. There should be a closing brace right after the "break" before the switch statement for randsnack1.
  3. Again the problem is repeated for the outermost switch statement for snack. There should be a closing brace right after the "break" before the switch statement for randperson1.
  4. Finally, the outermost switch statement for person is not closed. There should be a closing brace right after the "break" before the switch statement for randclue1.
Just as a tip, I'm sure this onNewpuzzle method can be reduced way down by using and loops and arrays for each category of strings. It shouldn't be thousands of lines of code. If you find yourself copying, pasting, and modifying large segments of code, you are doing the work the computer is meant to do.
Asker's Rating:
• I closed them up, and FINALLY I got the program to run. Unfortunately, for whatever reason, it's not doing what it is meant to do. Can I not write out the clues like I did? I thought you could do the "%d" thing, then call the replacement after the comma. I'm just going to put this project on hold until I know what I'm doing. Since you got it to go, you had the best answer, thank you!


Tags: switch, code

Helpful Answer?  (1)   (0)   

Helpful: dudemanguy

Tip srgothard for this answer
Permalink | Report
   Reply  
 
 
 
May 12, 2009 08:30 PM
You need to use %s for strings. %d is for integers. You probably need to use the sprintf function to do what you are doing.

Report
 
 

Other Answers (2)

Sort By
 
May 11, 2009 03:59 AM
What compiler are you using?

One possible issue, there's no semicolon here after your call to DECLARE_MESSAGE_MAP().

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

Helpful Answer?  (0)   (0)    Tip darth continent for this answer
Permalink | Report
   Reply  
 
 
 
May 11, 2009 04:24 AM
I'm VERY new to the world of programming, so whatever compiler I'm using is whatever comes on the Visual Studio 6 disk.

I tried playing around with that chunk, and nothing happened, which worries me, because you'd think if I added an extra ';' somewhere I'd at least get new errors. Thanks a lot for giving it a go, though; I didn't really think anyone would want to read through all of that mess. I already had to go through it once, correcting 100+ similar errors regarding the whole "switch" thing.

Report
 
 
 
May 11, 2009 01:21 PM
Yow.. did you inherit this code and are now having to maintain it or something? If you have a choice I'd suggest using both a newer version of Visual Studio, and a language like VB or C# which is in some ways a lot less confusing and easier to use than C++ for some tasks.

In the meantime you might try posting this on a Google Group or other newsgroup where C++ developers are lurking. You might also find some good leads at http://www.experts-exchange.com.

Good luck!!

Report
 
 
 
May 12, 2009 07:01 AM
This is what my uncle told me to use, and he's making 6 figures while I struggle at Mickey D's, so at first I trusted him, but now I realize that he's a little nuts. I had to BUY the VC++6 book, because the one he gave me was for visual studio 1.5! I think they still used punch cards back then, haha! So yeah, that might be the way to go, eventually, but for right now, he wants me to learn C++ AND VB, AND SQL (which I've never even been exposed to) and I think Perl is next, whatever that is. I think he thinks I'm a machine or something. But he's offering $40/hr to work part time out of my house, so he's the bo$$ :)

As far as programming groups, I've been looking at DaniWeb, but they seem a little high-and-mighty for me. They're too paranoid that someone is just gonna copy their answers for homework.

Report
 
 
 
May 11, 2009 06:31 PM
Ok, I looked at your code and the Error C1004: Unexpected end of file error is the least of your worries. This code really needs to be rewritten from scratch as you control structures are too large to be easily debugged. You have made one of the classic mistakes new programmers make, copying and pasting too many times. If you are going to do the same thing more than two times you should be creating a subroutine. When you use a subroutine you only have to debug and fix the code once not 100+ times. If this code is for a programming assignment don't hand it in! Even i it works you will undoubtedly fail the assignment. Spend a bit of time with paper and pencil to design your code before you write it.

If you really want to keep going down this path then here is some info on automatic braces matching in the VC++ tools. Good luck.

In languages other than Visual Basic, by placing the cursor to the left of a brace and pressing CTRL+], the cursor will move to the matching brace. http://msdn.microsoft.com/en-us/library/be94e8aw(VS.80).aspx
Automatic highlighting of matching braces for Visual Studio C++
http://www.codeproject.com/KB/macros/matchingbraces.aspx
Source(s):
20+ years of programming experience.


Helpful Answer?  (2)   (0)   

Helpful: orange, dudemanguy

Tip wdawe for this answer
Permalink | Report
   Reply  
 
 
 
May 12, 2009 06:51 AM
My uncle is trying to get me into programming so that I can help him out with his new business. He and my other uncle have been working together for a few years now making code "on demand" for various clients, and their work load is starting to get heavy. Since they both feel I'm a fast learner, they decided to give me a bunch of old VB, C++, and SQL books to get me started. They literally just threw me in a few weeks ago, and I suppose I'm sinking, but, luckily, no, this is not a homework assignment. I was just trying to make sure I got the idea of setting up a program, without reading it line for line out of a book.

First off, SAMS Teach Yourself Visual C++ 6 in 21 Days makes no mention of subroutines, so I haven't the slightest idea how to set one up. Books are stupid, and so am I. And good god, in all those lines of code, all I wanted to do was to randomly shuffle the the strings, so that each time I click the "New Puzzle" button, I get new clues to pop up on the dialog. Is there no "shuffle" function built in? I just can't think of a cleaner way to do this without running the risk of recurring strings. I can't have two Joe's! And believe me, I've learned my lesson with the cut/paste 'technique'. I spent 90 minutes adding braces and "break;" in SO MANY PLACES.

Thank you for your answer, but it's almost 2 am, and I have to wait and see if I can get this running in the morning. If you like to tell me a little about subroutines, I'd gladly throw in my last $1M as a tip. (I'm definitely going to have to invest in some serious mahalo dollars when I start college in the fall.)

Report
 
 

Answer this Question

How tips and payments work

This question has already been resolved. You may add an answer to it but you will not be eligible to win best answer or any associated tips.

Related Questions

No questions found.

Ask a Question


140 characters left
Top of Page
Buy Mahalo Dollars with Credit Card or PayPal

Top Members

This Week All Time
  • cfinke
    cfinke
    2nd Degree Black Belt
    26536 Points
    M$29.75 Earned
  • opher
    opher
    Purple Belt with a Brown Tip
    5371 Points
    M$215.59 Earned
  • thisjustme
    thisjustme
    Green Belt
    1143 Points
    M$76.05 Earned
   See All
 

Most Popular Tags

mahalo(1720)
music(489)
iphone(479)
google(376)
food(332)
online(328)
beer(282)
money(278)
movies(274)
apple(256)
aotd(235)
health(226)
video(219)
free(216)
dog(209)
   See All
 

Categories

Welcome New Members


 
 
Mahalo Dollars are the currency of Mahalo Answers.

Each Mahalo Dollar costs $1.

Once you earn more than 40 Mahalo Dollars, you can request to be paid via PayPal. Each Mahalo Dollar is currently worth $0.75 when paid out via PayPal. Learn More

 
 

Please log in to use this function.