IMPORTANT - READ BEFORE POSTING

There has been a significant influx of questions regarding C++ literature/books to learn from, so instead of posting yet another thread, have a look at this fantastic Stackoverflow article - The Definitive C++ Book Guide and List that covers the topic in great depth.

Flair your post as SOLVED if you got the help you were looking for! If you need help with flairs, check out ITEM 1 in our guidelines page.

Tips for improving your chances of getting helpful answers:

thoroughly research for an answer first.

give your post a meaningful title, i.e., NOT "I have a C++ problem" but, e.g., "Problem with nested for loops"

be specific.

make your questions relevant to other readers.

if your post does not appear in the new queue, just send a message to the moderators.

I can't figure out whats wrong with my code. When I compile it, the only error I get is "expected initializer before 'int' in line 9. I'm still pretty new and uneducated in this, so I'm not too sure what the heck is going on. Any help is appreciated.

When I compile after doing that, I get an error in line 19 that says "[Error] a function-definition is not allowed here before '{' token" and also in line 127 that says "[Error] expected '}' at end of input."

The compiler sees a function declaration missing a semicolon, or a function definition (illegal within another function) missing a body. I don't see any clue in the rest of the code as to what this line is supposed to accomplish anyway.

In general you probably really want to get a grip on how braces and semicolons are used. You have lots of extraneous braces which make the code difficult to read. You also have misplaced semicolons like in the following line which completely alter the behavior of the code:

Line 127 is probably related to the issue with line 18. Line 18 is not something I have seen before so I am a bit over my head on this one. I think it is telling you that it is upset that you are writing a function without it being in a function.

I know the original error because I see it all the time but this is something a bit over my head at this time.

I suggest you hit the basics. Start at the very beginning and understand the basics of C++ then attempt to debug this. There are just too many problems with this code. I think you'll most likely end up rewriting this, instead of trying to debug this.

You don't use a consistent indentation/bracketing style. It makes the code hard to read and parse.

Don't just throw around {}s. They limit the scope of variables. I get the feeling you mean to use indentation to separate blocks of code, but used {}s instead.

Functions like char letter( int c ) should be declared and defined outside the main() block. Read up on how to use functions in C++.

While not exactly a bad thing, you could use cout and cin from iostream instead of printf and scanf from stdio. Also, your headers. Unless you're from the past, you should use <cmath> instead of <math.h>, etc. Read up on this. Acquaint yourself with the standard C++ library.

Replying to my own comment. I mentioned some things about coding style and I thought you could use this. I've consciously tried to model my style after this and I think it makes for very clean, very readable C++ code. Enjoy: