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

  • Home
  • SEARCH
  • 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 7974501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:23:37+00:00 2026-06-04T08:23:37+00:00

I am new to pointers and I was wondering if someone can take a

  • 0

I am new to pointers and I was wondering if someone can take a look at my code and tell me why I am getting an error ” invalid conversion from Char to Char;

#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main (int argc, char * const argv[]) {
    int stringlenght;
    string  input;

    cout << "Please enter a  string >";
    getline(cin,input);
    cout << "You entered: " << input  << endl << endl;

    stringlenght=input.length();
    cout << stringlenght;

    char *inputArray[stringlenght];
    for (int i=0; i < stringlenght; i ++) {
        inputArray[i]=input[i];
    }

    //system("pause");
}
  • 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-06-04T08:23:39+00:00Added an answer on June 4, 2026 at 8:23 am

    The problem with your example is that you have declared inputArray as an array of pointers to characters, and therefore inputArray[i] will be a pointer to a character.

    What you are trying to do is assign the pointer at the i:th position in inputArray a character value.

    What I think you would like to do is to declare inputArray as:

    char *inputArray = new char[length];
    
    ... your loop ...
    
    delete []inputArray;
    

    This instead creates one pointer, and makes it point to a contigous area in memory where you can store characters, and therefore the type of inputArray[i] will be char instead of char *.

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

Sidebar

Related Questions

Apologies for the long code post but am wondering if someone can help with
I'm new to postgreSQL, so would really appreciate any pointers from the community. I
I was wondering what these 4 symbols mean. I am new to pointers in
Hi I am new to arraylists and java and I was wondering if someone
It's nothing new to de-couple the data access code from your business objects, but
I was wondering how you can do polymorphism with references, as opposed to pointers.
I'm new to pointers/memory operations and am working on some sample programs. I want
Firstly, I am very new to function pointers and their horrible syntax so play
I am a new C programmer and the pointers + arrays are messing me
I am new to C and I was reading about how pointers point to

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.