Click here to Skip to main content
15,888,037 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: IPC Thru WM_COPYDATA Pin
ForNow4-Feb-17 16:46
ForNow4-Feb-17 16:46 
GeneralRe: IPC Thru WM_COPYDATA Pin
Jochen Arndt4-Feb-17 23:37
professionalJochen Arndt4-Feb-17 23:37 
GeneralRe: IPC Thru WM_COPYDATA Pin
ForNow5-Feb-17 3:01
ForNow5-Feb-17 3:01 
GeneralRe: IPC Thru WM_COPYDATA Pin
ForNow5-Feb-17 14:19
ForNow5-Feb-17 14:19 
GeneralRe: IPC Thru WM_COPYDATA Pin
Rick York9-Feb-17 6:58
mveRick York9-Feb-17 6:58 
GeneralRe: IPC Thru WM_COPYDATA Pin
ForNow9-Feb-17 8:22
ForNow9-Feb-17 8:22 
AnswerRe: IPC Thru WM_COPYDATA Pin
leon de boer2-Feb-17 23:45
leon de boer2-Feb-17 23:45 
QuestionThr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba2-Feb-17 15:37
alalba2-Feb-17 15:37 
I want to inplement a binary search algorithm of an order array.
int Array::Search(int target, int* start, int* tail){
	if(start>tail){
		cout<<"not find"<<endl;
		return -1;
	}
	int offsetMid= (tail-start)/2/sizeof(int);//by unit of int
	cout<<"offset: "<<offsetMid<<"  mid " <<*(start+offsetMid)<<endl;
	cout<<start<<" " <<tail<<endl;
	if(target == *(start+offsetMid) ){
		cout<<"mid"<<endl;
		return (offsetMid+1);
	}
	if(*(start+offsetMid) > target){
		cout<<"left"<<endl;
		tail = start+(offsetMid-1)*sizeof(int);
		return Search(target, start, tail);
	}
	if(*(start+offsetMid) < target){
		cout<<"right"<<endl;
		start = start+(offsetMid)*sizeof(int);
		return Search(target,start , tail);
	}
}

But it doesn't work, I know the parameter of the func should better be the index of the array rather than a pointor, I just want to try this way. The compiler I used is
gcc version 6.2.1 20160916 (Red Hat 6.2.1-2) (GCC) 
Another weird thing
int offsetMid= (tail-start)/2/sizeof(int);//by unit of int
Both tail and start are the type of int*, but the difference of them is counted by byte, so I must divide it by sizeof(int) to get the offset value.
if(*(start+offsetMid) > target)
But when I want to plus the offset value to the start address to get the value in a particular position, I shouldn't time it by sizeof(int).WHY??

AnswerRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
Midi_Mick2-Feb-17 16:12
professionalMidi_Mick2-Feb-17 16:12 
GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba2-Feb-17 16:22
alalba2-Feb-17 16:22 
GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba3-Feb-17 4:05
alalba3-Feb-17 4:05 
AnswerRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
leon de boer2-Feb-17 23:18
leon de boer2-Feb-17 23:18 
GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba3-Feb-17 4:25
alalba3-Feb-17 4:25 
GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
leon de boer3-Feb-17 7:12
leon de boer3-Feb-17 7:12 
GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba3-Feb-17 12:46
alalba3-Feb-17 12:46 
SuggestionRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
David Crow3-Feb-17 3:47
David Crow3-Feb-17 3:47 
GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba3-Feb-17 4:26
alalba3-Feb-17 4:26 
AnswerRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
Patrice T8-Feb-17 6:20
mvePatrice T8-Feb-17 6:20 
QuestionStupid build issue - has to be an include file issue.... Pin
charlieg2-Feb-17 15:23
charlieg2-Feb-17 15:23 
AnswerRe: Stupid build issue - has to be an include file issue.... Pin
Peter_in_27802-Feb-17 16:18
professionalPeter_in_27802-Feb-17 16:18 
AnswerRe: Stupid build issue - has to be an include file issue.... Pin
leon de boer2-Feb-17 23:01
leon de boer2-Feb-17 23:01 
GeneralRe: Stupid build issue - has to be an include file issue.... Pin
charlieg3-Feb-17 1:05
charlieg3-Feb-17 1:05 
QuestionLNK2019 unresolved external symbol with Ultimate Toolbox COXTootlTipCtrl and ::MonitorFromRect Pin
Gagnon Claude30-Jan-17 5:02
Gagnon Claude30-Jan-17 5:02 
AnswerRe: LNK2019 unresolved external symbol with Ultimate Toolbox COXTootlTipCtrl and ::MonitorFromRect Pin
Richard MacCutchan30-Jan-17 6:35
mveRichard MacCutchan30-Jan-17 6:35 
GeneralRe: LNK2019 unresolved external symbol with Ultimate Toolbox COXTootlTipCtrl and ::MonitorFromRect Pin
Stefan_Lang30-Jan-17 21:39
Stefan_Lang30-Jan-17 21:39 

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.