unsigned int *pMessageLength, MessageLength; char *pszParsePos; ... //DATA into pszParsePos ... printf("\nMessage Length\nb1: %d\nb2: %d\nb3: %d\nb4: %d\n", pszParsePos[1],pszParsePos[2],pszParsePos[3],pszParsePos[4]); pMessageLength= (unsigned int *)&pszParsePos[1]; MessageLength = *((unsigned int *)&pszParsePos[1]); //Program Dies
Output:
Message length b1: 0 b2: 0 b3: 0 b4: 1
I do not understand why this harms my program. Can someone explain this, or at least suggest an alternative method that won't fail?
Thank you for your time!
, . , , , int , , *pszParsePos , int ( , , , , malloc), , &pszParsePos[1] .
int
*pszParsePos
malloc
&pszParsePos[1]
MessageLength, -
MessageLength
MessageLength = (pszParsePos[1] << 24) | (pszParsePos[2] << 16) | (pszParsePos[3] << 8) | pszParsePos[4]
( , , ). , , , , .
, :
, Blackfin Processor. -, , Blackfin , . , 32- / , 4 .
C [0], [1]. 4- char [3].
4- char, :
, 4- char 4- , , +1 , .
Source: https://habr.com/ru/post/1720307/More articles:ASSERT does not work when calling CDC SelectObject () - what can I try? - c ++TcpServer - sending and receiving data - c #Theme type for drawing the background into a bitmap in MFC - c ++Record on Youtube - youtube-apiHow to create a right-click event in all browsers - javascriptOptional parameter for pointer reference? - c ++How to find out which data type to use in Python? - pythonRake suppression in catalog message - ruby | fooobar.comBuffered HTTP POST reader - javaDecrypt UIViewController property warning - objective-cAll Articles