Code:
char func(int , int ,char *, char *);

int main (void)
{
 char str[MAX];
    char *temp;
    int y=0, counter=0;

    cout << "Enter String: ";
    fgets(str, MAX, stdin);
    temp = new char [strlen(str)];                

	*temp = UselessFunction(counter,y, temp, str);

	strcpy(str,temp);                   
	strrev(temp);                        

	if(strcmp(str,temp)==0)              
		cout << "\n\n Palindrome\n";
	else
		cout << "\nnot a Palindrome\n";
	
return 0;
}

char func(int counter, int y, char* temp, char* str)
{
	
	if (!isspace(str[counter]))         //removing spaces
	{
		temp[y] = str[counter];
		y++;
	}
	if (counter < strlen(str)-1)
		UselessFunction(++counter,y, temp, str);
	return *temp;
}
returning garbage