input parse error

This is a discussion on input parse error within the C++ Programming forums, part of the General Programming Boards category; The attached code looks (to me) like something that should compile perfectly. It's the pre-release command line version of a ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    86

    Question input parse error

    The attached code looks (to me) like something that should compile perfectly. It's the pre-release command line version of a mth utility. The only source I copied in the source that's getting an error.

    the reason several functions and a class are copied in before the main function is that when I tried to include the header file containing those functions and the class, I got this parse error before using namespace std;

    If anyone can tell me whats wrong with this code, I woudl be very greatful

    -Me
    Attached Files Attached Files

  2. #2
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    You're missing a closing brace in formatChange() somewhere, though I can't tell you where. All I know is that doing auto-tab on the code and then looking, the "end of the function" is indented an extra tab, and if I delete the whole function body and just leave an opening/closing brace and a return line, then it compiles fine.

    I really gotta say though, that must set a new record for code unreadability.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  3. #3
    Registered User
    Join Date
    Nov 2004
    Posts
    86

    input parse error

    ok, thanx for helping me out, I really appreciate it. I guess your right, my code tends to be unreadable, I write completely w/o comments, except on the ends of functions, methods, classes, if statements...etc

    But you dont have to be rude about it

    Just kidding

    thanx a lot

    -Me

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I guess your right, my code tends to be unreadable, I write completely w/o comments, except on the ends of functions, methods, classes, if statements...etc
    Don't worry about it, I don't even put comments on the ends of my functions But I do find long if-else chains rather messy, and I try to avoid them whenever possible. Add to that the fact that I usually line up my braces in a different style than you, and I call it unreadable

    Anyway, glad to have helped. Good luck!
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #5
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Unmatched brace '{' on line 268. Gotta love editors that math 'em up for you.
    Well, your code could stand to be reformatted a bit, but I have seen worse (much, much worse).

    Although you are completely free to disregard this, here are a few pointers:
    - Braces go on their own line... always. Both opening and closing braces.
    - The indentation of braces should match the indentation of what is outside of them.
    - Avoid skipping a line after every line. Instead, try to use whitespace for logical groupings.
    Code:
    int foo( )
    {
       if(...)
       {
          // Something
       }
       else
       {
          // Something else
       }
    
       while(1)
       {
          // More stuff...
       }
    }
    Just some guidelines that I personally use, but I do find that they help greatly with readability.

    Additionally, a lot of that functionality seems to be rather redundant, and hence prime for being made into a single function to get rid of a lot of the if...elses (e.g. the if(func =='...') { problem=... } stuff).

    Cheers
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,437
    This is what a typical block of code looks like when I first write it, having figured out beforehand what it is that I want to do.
    Code:
    while ( ) {
      if ( ) {
      } else if ( ) {
      } else {
      }
    }
    Then I know the braces will always match. Same goes for /**/ comments and "strings", type in the balancing part first, then reposition the cursor for the content.

    Another idea for you is to press "compile" every 10 lines of code, not every 1000 lines of code. If you've only added 10 lines, and you have a new compile error, then it's pretty easy to figure out where the new error is.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  2. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  3. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  4. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21