Link to home
Start Free TrialLog in
Avatar of purejamie
purejamieFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Explain this line of code!? : sprintf(buffer, "%d", argv[1][strlen(argv[1])-1]);

Hi experts,

I am pulling apart some old c code at work and have come accross a line I have litle idea about, hopefully it will be completely obvious to you guys.

The line is this:

sprintf(buffer, "%d", argv[1][strlen(argv[1])-1]);

The value of argv[1] is UK12398
Buffer evaluates to 56

I can't see how buffer evaluates to 56, can someone explain to me exactly the process that it goes through to get that number from UK12398

Many Thanks in advance
Jamie.
ASKER CERTIFIED SOLUTION
Avatar of imladris
imladris
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of purejamie

ASKER

Capital! Many Thanks.