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..

Recommended Answers

All 3 Replies

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.

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..

*(C + B) = A; = C[B] = A;
*(G + F + 1) = E; = G[f+1] = E;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.