Click here to Skip to main content
15,917,645 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: looping through a string Pin
Ryan Binns9-Jul-03 3:12
Ryan Binns9-Jul-03 3:12 
GeneralRe: looping through a string Pin
Cedric Moonen9-Jul-03 3:17
Cedric Moonen9-Jul-03 3:17 
GeneralRe: looping through a string Pin
si_699-Jul-03 3:24
si_699-Jul-03 3:24 
GeneralRe: looping through a string Pin
Ryan Binns9-Jul-03 3:56
Ryan Binns9-Jul-03 3:56 
GeneralRe: looping through a string Pin
Nuehli8-Jul-03 23:40
Nuehli8-Jul-03 23:40 
GeneralRe: looping through a string Pin
Ryan Binns8-Jul-03 23:44
Ryan Binns8-Jul-03 23:44 
GeneralRe: looping through a string Pin
keegan9-Jul-03 3:22
keegan9-Jul-03 3:22 
Generalarray problem... Pin
DaveE9th8-Jul-03 23:11
DaveE9th8-Jul-03 23:11 
The program below compiles with no errors and seems to run ok, but it doesn't work properly. When I enter in one of the 13 digit numbers stored in the array, I get back a message saying that the number I input is NOT in the array (but it is). What do I need to change? Confused | :confused:

Thanks, DaveBig Grin | :-D
-------------------------------------------------------



#include "stdio.h"
#include "math.h"
#include "iostream.h"
#include "stdlib.h"


double values[] = {5758020005287, 7937030006574, 4748020008574,
4847020007584, 9500020004758, 3849573800596 ,5758020005007,
7557030006574, 4745520008574, 4847020005584, 9585520004758,
3849573846696 ,3748596078661 , 4615243374995 , 1115364759770};

int compare (const void * a, const void * b)
{
#define ABS(a) ((a) < 0 ? -(a) : (a) )
double _a = *(double*)a;
double _b = *(double*)b;
if( ABS(_a - _b) < 0.00000001 )
return 0;
else if( _a < _b)
return -1;
else
return 1;
}
int main ()
{
double * pItem;
cout<<"please enter a number"<<endl;
double="" key;
cin="">>key;
pItem = (double*) bsearch (&key, values, 15, sizeof (double), compare);
if (pItem!=NULL)
printf ("%lf is in the array\n",*pItem);
else
printf ("%lf is not in the array\n",key);
return 0;
}




VC++ 6.0
GeneralRe: array problem... Pin
Alan Dugdall9-Jul-03 0:19
Alan Dugdall9-Jul-03 0:19 
GeneralRe: array problem... Pin
David Crow9-Jul-03 3:24
David Crow9-Jul-03 3:24 
GeneralRe: array problem... Pin
DaveE9th9-Jul-03 3:51
DaveE9th9-Jul-03 3:51 
GeneralFind Window Handles of a process Pin
parths8-Jul-03 22:53
parths8-Jul-03 22:53 
GeneralRe: Find Window Handles of a process Pin
Magnus Westin8-Jul-03 23:06
Magnus Westin8-Jul-03 23:06 
GeneralRe: Find Window Handles of a process Pin
parths8-Jul-03 23:14
parths8-Jul-03 23:14 
QuestionI have written a pipe-like class. Would you tell me some advices on it? Pin
xiaochnegwx8-Jul-03 22:37
xiaochnegwx8-Jul-03 22:37 
GeneralSTRANGE!!!!!!!!!! Pin
vcseeker8-Jul-03 22:19
vcseeker8-Jul-03 22:19 
GeneralAnyone????????? Pin
vcseeker9-Jul-03 1:23
vcseeker9-Jul-03 1:23 
GeneralRe: Anyone????????? Pin
Rage9-Jul-03 2:04
professionalRage9-Jul-03 2:04 
QuestionWhich one is best for Wait in a thread? Pin
chen8-Jul-03 21:53
chen8-Jul-03 21:53 
AnswerRe: Which one is best for Wait in a thread? Pin
Magnus Westin8-Jul-03 23:01
Magnus Westin8-Jul-03 23:01 
AnswerRe: Which one is best for Wait in a thread? Pin
Mike Dimmick8-Jul-03 23:14
Mike Dimmick8-Jul-03 23:14 
GeneralRe: Which one is best for Wait in a thread? Pin
chen9-Jul-03 0:09
chen9-Jul-03 0:09 
GeneralRe: Which one is best for Wait in a thread? Pin
Magnus Westin9-Jul-03 7:14
Magnus Westin9-Jul-03 7:14 
GeneralCommand Line Options Pin
BoudewijnEctor8-Jul-03 21:44
BoudewijnEctor8-Jul-03 21:44 
GeneralRe: Command Line Options Pin
giorgos8-Jul-03 21:52
giorgos8-Jul-03 21:52 

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.