See this Link :
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/
Format for sprintf
%[flags][width][.precision][length]specifier
now
%.2lx - % -> as format before flags
-> .2 - precision : specifies the minimum number of digits to be written.
-> l - Length : long int or unsigned long int
-> x - specifier : Unsigned hexadecimal integer