I'm not sure I entirely understand your assignment. You say
1) Read array 1
2) Read array 2
3) Output array 1
But your output only shows the last 8 characters of array 1.
3) ¿Output the last N characters in array 1?
What I don't understand is why you then need to "filter" the arrays. How are the arrays filtered?
BTW.
Line 39, Line 43: ¿Why are you multiplying tam by 2? This permits a buffer overrun. The argument should be exactly the maximum number of characters available:
cin.getline(arr1, tam);
You also have a filtered/unfiltered input problem between lines 36,39 and 41,43. Fix it by getting rid of the Enter key left in the input from when the user typed in a number for
tam.
36 37 38 39 40
|
cin >> tam;
cin.ignore( numeric_limits<streamsize>::max(), '\n' );
char* arr1 = new char[tam];
cin.getline(arr1, tam);
|
Also, you can reuse
tam -- no need to create a new variable.
41 42 43 44 45 46
|
cin >> tam;
cin.ignore( numeric_limits<streamsize>::max(), '\n' );
char* arr2 = new char[tam];
cin.getline(arr2, tam);
|
Hope this helps.
[edit] Alas, I took a shortcut and made a mistake. See
mbozzi's post below. Fixed here. [/edit]