Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6650763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:55:52+00:00 2026-05-26T00:55:52+00:00

I will be as specific as possible.. I have this code: // bintodec.cpp :

  • 0

I will be as specific as possible..
I have this code:

// bintodec.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

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

I’m trying to REWRITE/SIMPLIFY IT..to:

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

I have:

int j=0,x;
    double dec, y;
        char base, inp;

        cout << "Input a number: ";
    cin >> inp;
    cout << "Input the base your number is in: ";
    cin >> base;


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

For some reason its not working..visual studio is reporting that:

  1. left of ‘.length’ must have class/struct/union type is ‘char’
  2. subscript requires array or pointer type
  3. ‘++’ needs l-value
  4. syntax error : missing ‘;’ before identifier ‘j’

I want to rewrite and simplify it..help with errors please..thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:55:52+00:00Added an answer on May 26, 2026 at 12:55 am

    1: You can’t do inp.length() because you declared inp as a char. And a char isn’t a string.

    Try declaring inp as a string:

    string inp;
    

    2: “subscript requires array or pointer type”

    Same reason as above. inp is a char and not an array or a string.

    3/4: “‘++’ needs l-value”

    You’re missing a semicolon after: dec=dec + (x*y)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a certain service where specific functions will take longer to call than
This one will take some explaining. What I've done is create a specific custom
this isn't asp.net specific, some of these apps are WinForms, also will be adding
What is the issue with this code? Here we have two files: classA.h and
I have was wondering how it would be possible to show the specific time
I need a starting point to make the following possible. I have a Main
I have 10 items that when long clicked, will bring up an item specific
I am currently working on a project that will store specific financial information about
I'm trying to create a basic system that will allow only specific users to
I'm looking for a very specific eclipse plugin that will tell me if a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.