|
1/ Please use the code block formatting, and the preview button - you'll be amazed how much easier your code is to read.
2/ As suggested, run your program with a pen and paper. You'll be surprised how much it helps.
3/ I'll give you a big clue you're already been given.
int smallest = 0;
if (j < smallest) { smallest = j; }
3a/
Think about how many numbers are smaller than zero. Are the numbers you've entering small than zero?
Changing it to 1 only makes things better than one.
3b/ You'll have the same problem with largest, if you type in all negative numbers.
Enjoy,
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Initialize smalltest to the largest 4 byte integer :
int smallest = 4294967295 ;
if (j
|
|
|
|
|
*I* know that... though I'd recommend using MAX_INT...
But I was trying to lead the obviously a homework question in the right direction.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi
In my MFC dll I have this code in function:
HINSTANCE hInstance = AfxFindResourceHandle(MAKEINTRESOURCE(iID), RT_RCDATA);
return ::PlaySound(MAKEINTRESOURCE(iID), hInstance, SND_RESOURCE | SND_ASYNC | SND_NODEFAULT);
wave file is in resource of the dll, but when I call it from the exe, it can't play it, because it can not find it, (there is no RT_WAVE type!)
how can I play a wave file that is in a dll file?
Thanks
www.logicsims.ir
|
|
|
|
|
Hi,
I have a Multiline Dialog Box would anyone have the sequence
of Win32 SDK API calls to calculate/set the number of characters in a
Line of a Multiline Dialog Box
BTW I am using Rich Edit 2.0 though I don't think this has any
bearing on my question
|
|
|
|
|
i guess it's done automatically
Don't try it, just do it!
|
|
|
|
|
what about CRichEditCtrl::GetTextLength() ?
how dumb of me... shoulda read the whole thing.
what about getting the whole text and looking for CR-LF and counting the characters between them ?
This signature was proudly tested on animals.
|
|
|
|
|
I am using Plains old C so EM_LINELENGTH
But if I cann't fit the Number of Characters I want on the Line
I would to some how want to make the font smaller ???
I guess I shoud re-prhase the question if I for Instance want 12
characters on one line of a MultiLine Dialog Box How Can I
calculate/set the right Font ??
|
|
|
|
|
I'm useing MFC and have a SDI app with Doc/View architecture. The main window has got two pane horizontally. Now I'm gonna change their height programmatically; but how?
Thank you masters!
|
|
|
|
|
|
See here[^].
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hello everyone,
Anything wrong with my code below? I got the compile error!
typedef unsigned char BYTE;
void foo(char* & p)
{
return;
}
int main()
{
BYTE * buffer;
foo ((char*)buffer);
return 0;
}
thanks in advance,
George
|
|
|
|
|
this isnt strange as foo required char*& and not char*.
Don't try it, just do it!
|
|
|
|
|
My confusion is reference type is the same as original type, for example when type Foo is needed, we could pass Foo or pass Foo&. So, I think then char* & is needed I could pass char*? What is wrong with my understanding?
|
|
|
|
|
BYTE is an unsigned char (8 bit)
char* is a pointer (32 bit)
When converting BYTE to char* then it needs to create a temporary variable. It is not possible to make return-by-reference with temporary variables.
Instead make the conversion from BYTE to char* by using a local variable, and then pass that local variable to the function.
|
|
|
|
|
I agree with your points, but confused. Since I am using BYTE* not BYTE.
Anyway, could you show me your code please? I think code clarifies everything.
regards,
George
|
|
|
|
|
Where is he converting a BYTE to char*? He's converting a BYTE* to char*. In other words, unsigned char* to char*. I think there's no problem with the pointer size.
this is enough:
foo ((char*&)buffer);
|
|
|
|
|
It's all to do with the semantics of casting - you can't pass a reference to something you've produced with a cast, even if the size and location of the thing is the same.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You must call it as below
char* pp = (char*)buffer;
foo(pp);
«_Superman_»
|
|
|
|
|
Your code fixes my issue, but why? I think both your code and my code are of the same effect.
regards,
George
|
|
|
|
|
When you typecast, you have to give the destination exactly as it should be.
So you could also typecast if as foo((char*& )buffer)
«_Superman_»
|
|
|
|
|
It's all to do with the semantics of casting - you can't pass a non-const reference to something you've produced with a cast, even if the size and location of the thing is the same.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
hi,
I have an application which loads some images. when I changes the screen resolution position of images gets changed. How to manage image position while changing the screen resolution.
Thanks
|
|
|
|
|
what images? where are they displayed? how are they displayed?
Don't try it, just do it!
|
|
|
|
|
You can check new resolution with GetSystemMetrics.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|