how to check and remove leading zeroes from the buffer using c program

Helo ,
I m writing small module of c.on RHEL 4

I have one buffer (for e.g. buffer = "002"
now I want to check whethere buffer contains leading zeroes and if it contains
leading zeroes then I want to remove all leading zeroes
( i.e. if buffer = "002" then I want to make buffer = "2")

how do I do using c code

Regards,
Amit

/* usage example 
   void foo()
   {
      char z[4]{0x0};
      strcpy(z,"002");
      trim_leading(z, '0');
   }
*/
#include <string.h>

char *trim_leading(char *dest, int char_to_trim)
{
	char *p=strdup(dest);
	if(*p)
	{
	    while (*p && *p == char_to_trim) p++;
	    strcpy(dest,p);
	}
	free(p);
	return dest;	
}