Though some complilers supports its own language extensions nevertheless variable length arrays
cin>>n;
char a [n][50];
int arr [n][50];
is not a standard C++ feature. So instead them it is better to use the standard container std::vector.
It seems in this statement
arr[i][50]=a[i][50];
you are trying to assign one array to another array. Apart from the expressions are incorrect arrays do not have the assignment operator.
Below is a demonstrative program that shows how to perform your task.
#include <iostream>
#include <string>
#include <limits>
#include <array>
#include <vector>
#include <iterator>
#include <algorithm>
#include <cstring>
int main()
{
const size_t N = 50;
std::cout << "Enter the number of strings: ";
size_t n;
std::cin >> n;
std::vector<std::array<char, N>> strings( n );
std::vector<std::array<int, N>> values( n );
std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
for ( size_t i = 0; i < strings.size(); i++ )
{
std::cin.getline( strings[i].data(), N, '\n' );
}
for ( size_t i = 0; i < strings.size(); i++ )
{
std::cout << strings[i].data() << '\n';
}
for ( size_t i = 0; i < strings.size(); i++ )
{
size_t len = std::strlen( strings[i].data() ) + 1;
std::copy( strings[i].data(), strings[i].data() + len, std::begin( values[i] ) );
}
for ( const auto &row : values )
{
for ( auto it = std::begin( row ); *it != 0; ++it )
{
std::cout << *it << ' ';
}
std::cout << '\n';
}
return 0;
}
The program output might look the following way
Enter the number of strings: 2
Hello
World
72 101 108 108 111
87 111 114 108 100
char a [n][50];in standardc++nmust be a compile time constant. stackoverflow.com/questions/1887097/…arr[i][50]=a[i][50];is undefined behavior. You are accessing 1 past the end of the 2d arrays. valid indices are arr[0][0] to arr[n-1][49]cin>>a[i];do? What is even the purpose of[50]?n's position during both array declarations invokes undefined behavior, which, if you're unaware, is really bad and probably part of the source of your crash (although it might depend on your compiler whether or not you can get away with it this time. Since you're crashing, though, I'm assuming you're not.).arr[i]evaluates as a pointer to the data ofarr[i][0]which is then printed as a pointer.