Ok i am working on a program for class to add to big numbers. The numbers are entered as Chars then converted to int. Then i need to place them into a dynamically allocated array with a pointer. I need to do this twice to make two arrays and the pass both arrays to a function and add them together. First i am working on just getting the first array built and filled. Here is my code.
int _tmain(int argc, _TCHAR* argv[])
{ int size;
char data1;
int *pointer1;
cin>>size;
cin>>data1;
data1=data1-48;
pointer1=new int[size];
for(int i=0;i<size;i++)
{pointer1[i]=data1;
cout<<*pointer1;
}
return 0;
}
It needs some work because it only prints the first char i enter. So if i enter 3 for the size and 123 for the data. My array prints 111. I need 123. Also does anybody know how i can enter the data first then find the size of the data so i don't have to enter that from the keyboard.
It needs to work like if i enter 123 for data. It will automatically make size equal 3 then print the array 123.