Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have the following line of code in my program:

C++
StringCbPrintfA(szString,sizeof(szString),"INSERT INTO ClassRecord(SchInfoID,ArmNameID,ClassNameID,ClassTypeID,SessionID) VALUES(%u,%u,%u,%u,%u)",iSchInfoID,iArmNameID,iClassNameID,iClassTypeID,iSessionID);



where the relevant types are

C++
long long &iSchInfoID;

 long long iArmNameID, iClassNameID, iClassTypeID, iSessionID;



intellisence shows that:

C++
iSchInfoID 1
iArmNameID 1
iClassTypeID 1
iSessionID 1


But 0 is placed in the buffer for iArmNameID.

What could be wrong?
Posted

1 solution

Your types are "long long" but the format specifier is "%u".

Try "%llu" for an unsigned 64 bit value.
 
Share this answer
 
Comments
Gbenbam 18-Dec-14 17:17pm    
I tried it.It successfully formatted the first three variable, but the remaining variable were rendered as a long unending string of numbers.

It is not compulsory that I make it unsigned. It is somehow compulsory that I make it 64 bit.
Please what is the format code for 64 bit integer? It is because I dont't really know it that I used that.

Previous to posting this question, I had tried, "%d" but got the same result.
Gbenbam 18-Dec-14 17:34pm    
I was finally able to fix it.The garbage that was previously produced was due to the fact that iClassTypeID was of type INT_PTR and i used llu for it.

Once again, thanks a lot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900