simplifying and rewriting my code
<p>I will be as specific as possible..
I have this code:</p>

<pre><code>// bintodec.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

int main(){
    string inp;
    int dec = 0;
    char base;
    cout &lt;&lt; "Input a number: ";
    cin &gt;&gt; inp;
    cout &lt;&lt; "Input the base your number is in: ";
    cin &gt;&gt; base;
    for (int i = inp.length()-1, j = 0; i &gt;= 0; i--, ++j)
        dec += (inp[i]-48) * pow((float)base-48, j);
    cout &lt;&lt; "Your number in base 10 is: " &lt;&lt; dec &lt;&lt;endl;
    system("pause");
    return 0;
}
</code></pre>

<p>I'm trying to REWRITE/SIMPLIFY IT..to:</p>

<pre><code>{
    int j=0,x;
    double dec,y;
    for(int i = inp.length()-1; i &gt;= 0; i--) 
    {
    x=(inp[i]-48);
    y=pow((float)base-48, j);
    dec=dec + x * y;
    ++j;
    }
}
</code></pre>

<p>I have:</p>

<pre><code>int j=0,x;
    double dec, y;
        char base, inp;

        cout &lt;&lt; "Input a number: ";
    cin &gt;&gt; inp;
    cout &lt;&lt; "Input the base your number is in: ";
    cin &gt;&gt; base;


        {
            for (int i = inp.length()-1; i&gt;=0; --i)
            x=(inp[i]-48);
            y=pow((float)base-48, j);
            dec=dec + (x*y)
                ++j;
            {
             return 0;
</code></pre>

<p>For some reason its not working..visual studio is reporting that:</p>

<ol>
<li>left of '.length' must have class/struct/union type is 'char'</li>
<li>subscript requires array or pointer type</li>
<li>'++' needs l-value</li>
<li>syntax error : missing ';' before identifier 'j'</li>
</ol>

<p>I want to rewrite and simplify it..help with errors please..thanks!</p>
