Link to home
Start Free TrialLog in
Avatar of xneo27
xneo27

asked on

C++ Error about parenthesis

Heres my code:

//The convert function takes a string of numbers and returns its integer value.
int convert(string strNum)
{
      char c;
      const int Size = strNum.size();
      int I;
      int J;
      int X;
      int Y;
      int total;
      int tmpint1;
      int tmpint2;
      const int plusone = Size + 1;
      
      for (I = 1, I < plusone, I++)
      {
            X = Size - I;
            if (X > 0)
            {
                  Y = 10;
                  for(J = 1, J < X, J++)
                  {
                        Y = Y * 10;
                  }
            }
            else Y = 1;
            c = strNum.substr(I,I);
            tmpint1 = c - '0';
            tmpint2 = tmpint1 * Y;
            total = total + tmpint2;
      }
      return total;
}


Heres the odd errors im getting:

sr1 $ CC -o Program08 Program08.cpp
"Program08.cpp", line 170: Error: Unexpected ")" -- Check for matching parenthesis.
"Program08.cpp", line 171: Error: Use ";" to terminate statements.
"Program08.cpp", line 171: Error: Expected an expression.
"Program08.cpp", line 176: Error: Unexpected ")" -- Check for matching parenthesis.
"Program08.cpp", line 177: Error: Use ";" to terminate statements.
"Program08.cpp", line 177: Error: Expected an expression.
"Program08.cpp", line 182: Error: Cannot assign std::string  to char.
7 Error(s) detected.

Can anyone tell me why im getting these errors... If you need more code I can post it but I commented out this function and the errors disappeared
ASKER CERTIFIED SOLUTION
Avatar of callrs
callrs

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of callrs
callrs

http://www.oopweb.com/CPP/Documents/CPPHOWTO/Volume/C++Programming-HOWTO-7.html    string class

That shows how to use substr. E.g.
string str("Hello Universe!");
string start = str.substr(0, 5);
string end = str.substr(5);