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 8539009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:15:37+00:00 2026-06-11T11:15:37+00:00

I want to start off by saying that I have almost no experience with

  • 0

I want to start off by saying that I have almost no experience with C++ but I am taking a college class for it this semester and was just sort of messing around so that I am a little better prepared for the class. I know a good amount of Java but almost no C++.

Basically, I want to make some integers part of a string that will go into a string 2D Array. Then I want to print out just to make sure that everything is in the array…I realize that the second for loop isn’t really necessary but I put it there anyway.

My problem is that I keep getting an error message when trying to do:

myArray[i][j] = "(" << i << "," << j << ")";

Specifically, it tells me:

error: invalid operands of types 'const char*' and 'const char [2]' to binary 
       'operator+'

I don’t understand this error nor do I know how to fix it…

Here is what I have.

int height = 5;
int width = 5;
string myArray[height][width];

for (int i = 0; i < height; ++i) {
    for (int j = 0; j < width; ++j) {
        myArray[i][j] = "(" << i << "," << j << ")";
    }
}

for (int i = 0; i < height; ++i) {
    for (int j = 0; j < width; ++j) {
        cout << myArray[i][j] << "  ";
    }
}

I just want to know how to fix the error and then I would also like to know specifically why I am getting said error. 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-06-11T11:15:39+00:00Added an answer on June 11, 2026 at 11:15 am

    You get the error because that’s not the way to concatenate strings in C++. But the message is strange, since you appear to be using operator << and not operator +.

    Regardless, use a std::stringstream.

    std::stringstream ss;
    ss << "(" << i << "," << j << ")";
    myArray[i][j] = ss.str();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'll start off by saying that it's entirely possible that this isn't possible -
First off I want to start off saying that I don't know anything about
I'm going to start this off by saying that I am new to GLSL
Ok, let me start off by saying that I'm don't have the slightest clue
Let me start off by saying I don't want to print only the duplicate
I have a situation like this: start(); <Some code> end(); I want start() function
So, to start off, I want to point out that I know that these
Preface Let me start off by saying that I'm a relatively new programmer and
I'd like to start off by saying that I'm a complete beginner when it
First of all i want to start off by saying I'm kind of 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.