0

Hi all..

I saw a part of codes which I unable to understand..
pleaase all the expert teach me ya..
below is the part of codes..

UINT A;
USHORT B;
USHORT *C;
CString D;

if(!sscanf_s(D, "0x%x", &A))
    sscanf_s(D, "%d", &A);

*(C + B) = A; //<= what is the meaning..??

What is these codes means..??

Please help..

Thank you..
shizu..

3
Contributors
3
Replies
21
Views
2 Years
Discussion Span
Last Post by NathanOliver
0

The short answer is, it is using pointer arithmetic to compute the location of an index B in an array of USHORT (where USHORT is a typedef equal to unsigned short) pointed to by C (I assume that somewhere in the elided code, C is being set to either am array or a block allocated on the heap using malloc() or something similar), then dereferences the computed pointer so it can store the value of A at the pointed-to location. It is basically the same as

C[B] = A;

Except that it is (marginally) more efficient.

0

Hi..

I checked back the codes..
it didn't show that way..

UINT A;
UINT E;
USHORT B;
USHORT F; 
USHORT *C;
USHORT *G;
CString D;
CString H;

if(!sscanf_s(D, "0x%x", &A))
    sscanf_s(D, "%d", &A);

if(!sscanf_s(H, "0x%x", &E))
    sscanf_s(H, "%d", &E);

*(C + B) = A;//<= what is this means to..??
*(G + F + 1) = E;//<= what is this means to..??

Please advise..

Thank you..
shizu..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.