I have tried using:
cout<<"033[2j\033[01;1H"; I don't understand what it did to the terminal. Output: On the terminal
cout<<string(22, '\n'); This solution took the cursor 22 lines below, which I didn't want.
system('cls'); I included stdlib.h for it but I still got the same error and I'm unable to resolve it. Output: On the terminal
These were the solutions I could find but they don't help.
This is the code I'm trying it on:
#include <iostream>
using namespace std;
void rev_array(int arr[], int start, int end)
{
while(start < end)
{
int temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;
start++;
end--;
}
}
void print_array(int arr[], int size)
{
for(int i=0; i < size; i++)
cout<<arr[i]<<" ";
cout<<endl;
}
int main()
{
int n;
cout<<"Enter the size of array: ";
cin>>n;
int arr[n];
for(int i=0; i<n; i++)
cin>>arr[i];
cout<<"033[2j\033[01;1H";
print_array(arr, n);
rev_array(arr, 0, n-1);
cout<<"Reversed array is "<<endl;
print_array(arr, n);
return 0;
}