When I enter 2 values the third one is garbage..Don't Know why..
#include<iostream>
#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];
Encoded_Matrix_Column = matrix_size_checker(size,Encoded_Matrix_Column);
cout<<"It Has "<<Encoded_Matrix_Column<<" Columns"<<endl;
cout<<"It Hass 3 Rows"<<endl;
//Intilizing every point in 1D array with NULL
for(int i=0;i<size;i++)
{
Digits[i] = NULL;
}
// 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 = NULL,u=0;
Encoded_Matrix = new int*[3];
//Allocating memory to every point in 2D array
for(int i=0;i * Encoded_Matrix_Column <size;i++)
{
Encoded_Matrix[i]= new int[Encoded_Matrix_Column];
}
//Intilizing every point in 2D array with NULL
for(int i=0;i<Encoded_Matrix_Column;i++)
{
for(int j=0;j<3;j++)
{
Encoded_Matrix[i][j] = NULL;
}
}
//Coping the User input into 2D array
for(int i=0;i<Encoded_Matrix_Column;i++)
{
for(int j=0;j<3;j++)
{
if(Digits[u]==NULL)
{
Encoded_Matrix[i][j] = 0 ;
}
else
{
Encoded_Matrix[i][j] = Digits[u];
}
u++;
}
}
//Output of 2D Array
for(int i=0;i<Encoded_Matrix_Column;i++)
{
for(int j=0;j<3;j++)
{
cout<<Encoded_Matrix[i][j]<<" " ;
}
cout<<endl;
}
system("pause");
}