Sprintf-Objective C

I have this code.

sprintf((char *)pData,"%c%02X%c%02X% 02X",ASCII_STX,m_uSessionId,m_chSequenceChar,m_nMessageId,m_uVersion); NSLog("%@",pData); 

But its not printing me contents pData. Tried with %d as a format specifier.

+7
source share
2 answers

Try the following. It may not recognize pData as a string:

 NSLog( @"%s", pData ); 
+2
source

Perhaps you will use the Obj-C method?

 NSString *pData = [NSString stringWithFormat:@"%c%02X%c%02X%02X", ASCII_STX, m_uSessionId, m_chSequenceChar, m_nMessageId, m_uVersion]; NSLog(@"%@",pData); 
+14
source

All Articles