Click here to Skip to main content
15,910,773 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generaloffice automation using OLE Pin
chennailu15-Jun-03 15:09
susschennailu15-Jun-03 15:09 
GeneralPrevent ALT F4 Pin
Søren Alsbjerg Hørup15-Jun-03 13:33
Søren Alsbjerg Hørup15-Jun-03 13:33 
GeneralRe: Prevent ALT F4 Pin
Harsha Gopal15-Jun-03 15:27
Harsha Gopal15-Jun-03 15:27 
GeneralRe: Prevent ALT F4 Pin
Anonymous15-Jun-03 17:34
Anonymous15-Jun-03 17:34 
GeneralRe: Prevent ALT F4 Pin
Ryan Binns15-Jun-03 17:50
Ryan Binns15-Jun-03 17:50 
GeneralRe: Prevent ALT F4 Pin
Joan M16-Jun-03 0:48
professionalJoan M16-Jun-03 0:48 
GeneralRe: Prevent ALT F4 Pin
Ryan Binns16-Jun-03 1:01
Ryan Binns16-Jun-03 1:01 
GeneralCouple of questions concerning bits Pin
georgiek5015-Jun-03 11:27
georgiek5015-Jun-03 11:27 
I was under the impression (according to my programming book) that a left shift on a byte caused the bits on the left to "fall off" and zeros inserted to the right:

eg. 0x1F << 2 = 0xC0

but it equals 0x7C0

Why is this?

My reason for asking this question is that I am trying to find a four byte sequence within a file (MPEG-1) that doesn't seem to byte aligned. I wrote a little function to do a "bit by bit" search but since the above statement is not true it fails, here is my code (I feed it 64 bits at a time):

int FindSequenceHeader(unsigned char *str)
{
	// Does a bit by bit search for the sequence header

	char ch[4];

	DWORD dwValue;

	for (int x = 0; x < 4; x++)
	{
		for (int i = 0; i < 8; i++)
		{
			ch[0] = ( (str[x + 0] << (0 + i)) | (str[x + 1] >> (8 - i)) );
			ch[1] = ( (str[x + 1] << (0 + i)) | (str[x + 2] >> (8 - i)) );
			ch[2] = ( (str[x + 2] << (0 + i)) | (str[x + 3] >> (8 - i)) );
			ch[3] = ( (str[x + 3] << (0 + i)) | (str[x + 4] >> (8 - i)) );

			dwValue = ( ch[0] | (ch[1] << 8) | (ch[2] << 16) | (ch[3] << 24) );

			switch (dwValue)
			{
				case 0x000001b3:
					cout << "Video Sequence Header Found" << endl;

					return 0;

					break;

				default:
	
					break;
			}
		}
	}

	// Found nothing...
	return 1;
}


which then leads me to ask why this standard routine i've seen in many sample codes works:

DWORD MakeDword(unsigned char *str)
{
	return ( str[0] | (str[1] << 8) | (str[2] << 16) | (str[3] << 24) );
}


any thoughts?
GeneralRe: Couple of questions concerning bits Pin
adamUK15-Jun-03 11:52
adamUK15-Jun-03 11:52 
GeneralRe: Couple of questions concerning bits Pin
Toni7815-Jun-03 12:07
Toni7815-Jun-03 12:07 
GeneralRe: Couple of questions concerning bits Pin
georgiek5015-Jun-03 12:58
georgiek5015-Jun-03 12:58 
GeneralRe: Couple of questions concerning bits Pin
Harsha Gopal15-Jun-03 15:42
Harsha Gopal15-Jun-03 15:42 
GeneralRe: Couple of questions concerning bits Pin
georgiek5015-Jun-03 15:53
georgiek5015-Jun-03 15:53 
GeneralRe: Couple of questions concerning bits Pin
peterchen15-Jun-03 23:49
peterchen15-Jun-03 23:49 
GeneralText Object Model(Urgent) Pin
Asad Rasheed15-Jun-03 11:22
Asad Rasheed15-Jun-03 11:22 
GeneralRe: Text Object Model(Urgent) Pin
Ryan Binns15-Jun-03 17:55
Ryan Binns15-Jun-03 17:55 
QuestionHow Can i detect a radion button is clicked Pin
snipes15-Jun-03 11:14
snipes15-Jun-03 11:14 
AnswerRe: How Can i detect a radion button is clicked Pin
adamUK15-Jun-03 11:58
adamUK15-Jun-03 11:58 
GeneralRe: How Can i detect a radion button is clicked Pin
basementman16-Jun-03 4:20
basementman16-Jun-03 4:20 
GeneralWeb Browser control (questions) Pin
Member 43908315-Jun-03 10:29
Member 43908315-Jun-03 10:29 
GeneralRe: Web Browser control (questions) Pin
Tarundeep Singh Kalra16-Jun-03 3:53
Tarundeep Singh Kalra16-Jun-03 3:53 
GeneralRe: Web Browser control (questions) Pin
Member 43908316-Jun-03 13:07
Member 43908316-Jun-03 13:07 
GeneralRe: Web Browser control (questions) Pin
Neville Franks16-Jun-03 12:14
Neville Franks16-Jun-03 12:14 
GeneralRe: Web Browser control (questions) Pin
knappbl16-Jun-03 13:01
knappbl16-Jun-03 13:01 
GeneralRe: Web Browser control (questions) Pin
Member 43908316-Jun-03 13:08
Member 43908316-Jun-03 13:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.