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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:16:14+00:00 2026-06-05T20:16:14+00:00

I want to reverse a 2d array of type char using std::reverse() function in

  • 0

I want to reverse a 2d array of type char using std::reverse() function in the STL algorithm.

#include <iostream>
#include <algorithm>

int main()
{
    char array[10][5];

    initiate_array(array);              // this takes care of initializing array

    std::reverse(array, array + 10);    // <- error C2075

    return 0;
}

But I keep getting this error: C2075: '_Tmp' : array initialization needs curly braces
which I never encountered before!

I use MSVC++ 2008 to compile my code.

  • 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-05T20:16:15+00:00Added an answer on June 5, 2026 at 8:16 pm

    The root of the problem is that arrays cannot be assigned to one another. Let’s consider how std::reverse might be implemented:

    template<class BidirectionalIterator>
    void reverse(BidirectionalIterator first, BidirectionalIterator last)
    {
        while ((first != last) && (first != --last)) {
            std::swap(*first++, *last);
        }
    }
    

    and std::swap needs to be able to assign whatever arguments you give it, in order to swap them. In your case you have an array of arrays; So it’s trying to swap the char[5] array at array[0] with the one at array[10], which is not valid C++.

    However, in C++11 this does work as expected; not because you can now assign arrays, but because std::swap has gained an overload that makes it work for arrays, effectively mapping to std::swap_ranges. But you should realize that this is not just swapping pointers around, it’s swapping the array type individually (chars in your case).

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

Sidebar

Related Questions

I'm using Express JS and I want a functionality similar to Django's reverse function.
I want to use pointers to reverse a char array in C++. I was
I want to make a reverse string function and I have done it like
I'm not talking about array_flip() , i want to reverse an array without a
is there any function to get the keys of an array using javascript Also
I want to reverse an array (or any other data structure) but because this
I am saving some data in order using array s, and I want to
I want to reverse each individual word of a String in Java (not the
I have an AnimatedSprite that after it finishes the animation I want to reverse
I want to prevent my application from being reverse engineered and decompiled by someone

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.