Click here to Skip to main content
15,884,877 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Function pointer problem Pin
smags1320-May-11 7:43
smags1320-May-11 7:43 
GeneralRe: Function pointer problem Pin
Albert Holguin20-May-11 10:02
professionalAlbert Holguin20-May-11 10:02 
AnswerRe: Function pointer problem Pin
Paul Michalik20-May-11 23:10
Paul Michalik20-May-11 23:10 
QuestionSearch for bytes array in a binary file Pin
Smart Arab20-May-11 5:39
Smart Arab20-May-11 5:39 
AnswerRe: Search for bytes array in a binary file Pin
Albert Holguin20-May-11 5:47
professionalAlbert Holguin20-May-11 5:47 
GeneralRe: Search for bytes array in a binary file Pin
Smart Arab20-May-11 6:04
Smart Arab20-May-11 6:04 
GeneralRe: Search for bytes array in a binary file Pin
David Crow20-May-11 7:54
David Crow20-May-11 7:54 
AnswerRe: Search for bytes array in a binary file [modified] Pin
Albert Holguin20-May-11 7:54
professionalAlbert Holguin20-May-11 7:54 
If the size of the sequence is fixed, a better solution would be a state machine (this would also only find the first occurance of the byte sequence, but you can put it in a function and find all occurrences of the sequence)...
//Presented here in pseudo-code
bool found = false; 
int m_State = 1, origin = 0;
while((ch = getc(file) != EOF) && (!found))
{
	//State Machine
	switch(m_State)
	{
	case 1:
		if(ch == data[0]){
                        origin = ftell(file)- 1;
			m_State = 2;
                }
		break;
	case 2:
		if(ch == data[1])
			m_State = 3;
		else m_State = 1;
		break;
	case 3:
		if(ch == data[2])
			m_State = 4;
		else m_State =1;
		break;
	case 4:
		if(ch == data[3])
			found = true;
		else m_State = 1;
		break;
	}
}


modified on Friday, May 20, 2011 4:15 PM

QuestionHow do I update a Form from a function? Pin
Freddie Code20-May-11 4:53
Freddie Code20-May-11 4:53 
AnswerRe: How do I update a Form from a function? Pin
Freddie Code20-May-11 6:43
Freddie Code20-May-11 6:43 
Questiondamage after normal block( #24094) Pin
Sakhalean20-May-11 0:45
Sakhalean20-May-11 0:45 
AnswerRe: damage after normal block( #24094) Pin
Chris Losinger20-May-11 0:56
professionalChris Losinger20-May-11 0:56 
AnswerRe: damage after normal block( #24094) Pin
Malli_S20-May-11 1:18
Malli_S20-May-11 1:18 
Questionmatrix Rotation Pin
002comp20-May-11 0:08
002comp20-May-11 0:08 
AnswerRe: matrix Rotation Pin
Luc Pattyn20-May-11 1:42
sitebuilderLuc Pattyn20-May-11 1:42 
GeneralRe: matrix Rotation Pin
002comp20-May-11 2:56
002comp20-May-11 2:56 
JokeRe: matrix Rotation Pin
David Crow20-May-11 3:06
David Crow20-May-11 3:06 
QuestionFile creation time Pin
tasumisra19-May-11 22:56
tasumisra19-May-11 22:56 
AnswerRe: File creation time Pin
Richard MacCutchan19-May-11 23:18
mveRichard MacCutchan19-May-11 23:18 
GeneralRe: File creation time Pin
mosealex20-May-11 3:55
mosealex20-May-11 3:55 
GeneralRe: File creation time Pin
Richard MacCutchan20-May-11 4:23
mveRichard MacCutchan20-May-11 4:23 
AnswerRe: File creation time Pin
Chandrasekharan P19-May-11 23:25
Chandrasekharan P19-May-11 23:25 
QuestionDrawImage Pin
john563219-May-11 21:53
john563219-May-11 21:53 
GeneralRe: DrawImage Pin
Cool_Dev19-May-11 22:17
Cool_Dev19-May-11 22:17 
GeneralRe: DrawImage Pin
john563219-May-11 23:07
john563219-May-11 23:07 

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.