Thread: Weird function problems

  1. #1

    Question Weird function problems

    My compiler complains of '}' syntax errors all over the place in this function. I have to comment out the IF statements and their closing brackets (not the enclosed statements) to get it to compile. Take a look, and tell me if you see any problems.

    PHP Code:
    bool checkArgs(int countchar *value[]) {
      
    char *val;
      for (
    int i 1i<counti++) {
        
    val value[i];
        if (
    val[1] == '-')   // True if a switch is used
          
    if (val[2] == 'A'// 'A'dmin privileges
            
    cout << val << ": Admin Privileges Granted.\n";
          }
        }
      }
      return 
    true;

    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Count the number of opening and closing braces. they should match, but in your case they don't.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User Diamonds's Avatar
    Join Date
    Oct 2002
    Posts
    68
    Code:
    bool checkArgs(int count, char *value[]) {
      char *val;
      for (int i = 1; i<count; i++) {
        val = value[i];
        if (val[1] == '-')   // True if a switch is used
          if (val[2] == 'A') // 'A'dmin privileges
            cout << val << ": Admin Privileges Granted.\n";
        }
      return true;
    }

  4. #4
    [WHISPER]
    [CODE] tags...
    [/WHISPER]

    I see what i did wrong, i forgot to do if (...) {
    hehe......

    thanks, guys.
    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  2. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  3. sin() function problems.
    By Lifedragn in forum C Programming
    Replies: 4
    Last Post: 09-28-2004, 11:16 PM
  4. Replies: 5
    Last Post: 02-08-2003, 07:42 PM
  5. Big problems with the Text function
    By GaPe in forum C Programming
    Replies: 26
    Last Post: 05-22-2002, 10:42 AM