#include <iostream>
#include <string.h>
using namespace std;

char *reverse(char *str, int count = 0)
{
	if(count == 0){
		count = strlen(str);
	}
	char *buf = new char[count + 1];
	
	for(int i = 0; i < count; i++){
		buf[count - i - 1] = str[i];
	}
	buf[count] = '\0';
	return buf;
}

int main()
{
	cout << reverse("abcde") << "\n";
	cout << reverse("abcde", 3) << "\n";
	
	return 0;
}
