DarkLeafyGreen
DarkLeafyGreen

Reputation: 70406

C++, sprintf with hex parameter

I try to understand following code:

char temp[50];
sprintf(temp,"%04XT1000A",Edit3->Text.ToInt());

I know that T1000A is a simple string and I know the meaning of it, but what is %04X? Is %04X completely replaced by the parameter?

Upvotes: 1

Views: 1559

Answers (1)

Ivaylo Strandjev
Ivaylo Strandjev

Reputation: 70931

%04 is a format specifier modifier saying that if the output is less than 4 chars it should be padded on the left with 0. %X is standard format specifier meaning print unsigned hexadecimal use capital letters for A-F. Have a look at printf's documentation.

Upvotes: 9

Related Questions