Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C++ Error about parenthesis

Posted on 2006-11-03
2
Medium Priority
?
281 Views
Last Modified: 2010-04-16
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
0
Comment
Question by:xneo27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 30

Accepted Solution

by:
callrs earned 2000 total points
ID: 17868388
for (I = 1, I < plusone, I++)         |   for(J = 1, J < X, J++)
should be
for (I = 1; I < plusone; I++)        |    for(J = 1; J < X; J++)
0
 
LVL 30

Expert Comment

by:callrs
ID: 17868455
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);

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question