Logo 
Search:

C++ Programming Forum

Ask Question   UnAnswered
Home » Forum » C++ Programming       RSS Feeds

How to Copy the value from 1D pointer to 2D pointer

  Asked By: Muhammad    Date: May 02    Category: C++ Programming    Views: 23758
  

I want to copy the value of the digits pointer to the Encoded Matrix.The Problem is when i run the program it takes input but break while coping the values. Thanks in Advance for Help :)

#include<iostream>
#include<Digits_To_Letter_Converter.h>
#include<Size_Decider.h>

using namespace std;

int main()
{
int size=0,Encoded_Matrix_Column=1;
cout<<"Enter The Number of Digits ";
cin>>size;

int *Digits= NULL;
Digits = new int[size];

//Intilization Of Digits Array
for(int i=0;i<size;i++)
{
Digits[i] = NULL;
}

Encoded_Matrix_Column = matrix_size_checker(size,Encoded_Matrix_Column);
cout<<"It Has "<<Encoded_Matrix_Column<<endl;
// Input fro the user to enter the Digits for Further Process
for(int i=0;i<size;i++)
{
cout<<"Enter The Digit "<<i+1;
cin>>Digits[i];
}

int **Encoded_Matrix = new int*[size],u=0;


for(int i=0;i<Encoded_Matrix_Column;i++)
{
for(int j=0;j<3;j++)
{
Encoded_Matrix[i][j] = Digits[u];
u++;
}
}
for(int i=0;i<Encoded_Matrix_Column;i++)
{
for(int j=0;j<3;j++)
{
cout<<Encoded_Matrix[i][j]<<" " ;
}
cout<<endl;
}
}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on How to Copy the value from 1D pointer to 2D pointer Or get search suggestion and latest updates.




Tagged: