|
sure it is big for me to do..can you please tell my teacher that information.....so he may discard me from this project...
so if you please can you help me...with some more technical information for a beginner....thanks
|
|
|
|
|
Hi !
Is there a way in standard C++ to programmatically get the limits of an int (i.e the smallest possible number and the biggest possible number) ?
Thanks !
Jerome
|
|
|
|
|
int max=0,min=0;
min = min-1; //smallest possible number;
max = -min + 1; //largest possible number;
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
Mr.Prakash wrote:
int max=0,min=0;
min = min-1; //smallest possible number;
max = -min + 1; //largest possible number;
????
Well, I don't see how it could work.
min = min -1 gives -1 for min.
max = -min + 1 gives 2 for max, isn't it ?
Jerome
|
|
|
|
|
Yak!! what was i thinking.
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
std::numeric_limits<int>::min()
std::numeric_limits<int>::max()
|
|
|
|
|
Thanks for your help !
I still have a problem though :
I do :
#include <limits>void main()
{
int LowerLimit=std::numeric_limits<int>::min();
}
And I get these errors when I compile :
warning C4003: not enough actual parameters for macro 'min'
error C2589: '(' : illegal token on right side of '::'
error C2059: syntax error : '::'
I'm using VS 6.
Any idea ?
Thanks !
Jerome
|
|
|
|
|
First time I posted, the forum removed my <int> - I forgot to check the checkbox "Do no treat <'s as HTML tags".
I should be:
#include <limits>
LowerLimit=std::numeric_limits<int>::min();
its a template class - you can use it for any primitive data type, eg.
std::numeric_limits<float>::min();
std::numeric_limits<double>::max();
|
|
|
|
|
<small><b>Rowan Seymour wrote:</b></small>
<i>I forgot to check the checkbox </i>¨
So did I !!!
Here is the line I have in my code :
int LowerLimit=std::numeric_limits<int>::min();
and the errors I get :
warning C4003: not enough actual parameters for macro 'min'
error C2589: '(' : illegal token on right side of '::'
error C2059: syntax error : '::'
It looks like 'min' has many definitions, but the namespace should do it, right ?
I don't see what I'm doing wrong !
Jerome
|
|
|
|
|
|
yes, and using namespace std !
strange....
|
|
|
|
|
Try the following program:
#include <limits>;
#include <iostream>;
int main()
{
int LowerLimit=std::numeric_limits<int>::min();
int UpperLimit=std::numeric_limits<int>::max();
std::cout << LowerLimit << '\n'
<< UpperLimit << std::endl;
}
Don't use any other include statements.
|
|
|
|
|
min is a Win32 macro computing minimum of two parameters. It intererferes with the numeric_limits<>::min() function. The similar example is min(x, y) and max(x, y) function in <algorithm> , so in stl header files distributed with VC are defined as _cpp_min and _cpp_max . But there isn't any similar definition in numeric_limits.
You can use the INT_MIN , INT_MAX macros from limits.h . The numeric_limits class is only a STL wrapper around these macros.
HTH.....Robert-Antonio
|
|
|
|
|
INT_MIN, SHRT_MIN, SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, SHRT_MAX, USHRT_MAX, INT_MAX, UINT_MAX - all defined in ANSI-C and C++, including VS6, see limits.h
Bernd
|
|
|
|
|
Sure. Just use sizeof() in a standard (2**n - 1) calculation to get the most -ive and most +ive number that can be stored in an int . Imho, that's the real programmatic way of figuring this out.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Dear All,
Code project people has helped me a lot during my initial career by flooding me with useful solutions & valuable comments to my doubts. Thanks a lot for that.
I have another small question. I am developing an application in which I am running an executable (the job of this exe is to move some files from one location to the other, etc.). This exe is built using "Win32 Console application" provided in Visual C++ Version 6.0
When I run the application, it calls my exe, and this running exe shows its console window and performs its required operation successfully and close downs decently. BUT I DONOT WANT THAT CONSOLE WINDOW TO BE DISPLAYED DURING MY APPLICATION.
I cannot change the application since I don’t have the code for that, but I can easily do the same for my exe. So can any body please tell me how to hide the console window or console should not be displayed.
Regards,
Rohit Dhamija
|
|
|
|
|
In VB, it would be simple:
Shell "foobar.exe", vbHide
modified on Monday, August 30, 2010 6:46 AM
|
|
|
|
|
See the Console class on my website www.xfcpro.com, under the freestuff section for the full code, but here is a sample of what you need to do.
HWND Console::GetConsoleWindow9X()
{
HWND hWndConsole = NULL;
TCHAR szTempTitle[_MAX_PATH];
TCHAR szTempOldTitle[_MAX_PATH];
if(GetConsoleTitle(szTempOldTitle, _MAX_PATH) > 0)
{
WCHAR szBuff[_MAX_PATH];
memset(&szBuff, 0, _MAX_PATH);
GUID obGuid;
CoCreateGuid(&obGuid);
StringFromGUID2(obGuid, szBuff, _MAX_PATH);
wsprintf(szTempTitle, "%ws", szBuff);
SetConsoleTitle(szTempTitle);
Sleep(50);
if((hWndConsole = FindWindow(_T("tty"), szTempTitle)) == NULL)
if((hWndConsole = FindWindow(_T("ConsoleWindowClass"), szTempTitle)) == NULL)
hWndConsole = FindWindow(NULL, szTempTitle);
SetConsoleTitle(szTempOldTitle);
}
return hWndConsole;
}
void Console::ShowConsoleWindow(bool bHide )
{
HWND hWndConsole = NULL;
#if(_WIN32_WINNT >= 0x0500) // Windows 2000 and later only
hWndConsole = GetConsoleWindow();
#else
hWndConsole = GetConsoleWindow9X();
#endif
ShowWindow(hWndConsole, (bHide) ? SW_SHOW : SW_HIDE);
iLastErrorCode_ = XFC_SUCCESS;
}
regards,
Dark Angel
|
|
|
|
|
Thanks Dear,
I am developing my application only for Windows2000 (no Win9x systems)
So I there any simpler way out for my doubt ??
Thanks a lot.
Regards,
Rohit Dhamija
|
|
|
|
|
Hi Rohit,
For Windows 2000 just add the following function to your code and call it at the start of your application.
void ShowConsoleWindow(bool bHide )
{
ShowWindow(GetConsoleWindow(), (bHide) ? SW_SHOW : SW_HIDE);
}
Then to hide the console window, call:
<code>
ShowConsoleWindow(true);
and to show it again (if necessary):
<code>
ShowConsoleWindow(false);
best wishes,
Dark Angel
|
|
|
|
|
Hello,
in my application I use the activex component msflxgrd.ocx. I use it in a dialog and in a view. At a PC without visual c++ installed I only can see the component in the dialog not in the view. I copy the component in C:\Winnt\system32, and I register it.
Do I need some dll or library?
Thank you.
|
|
|
|
|
Hi,
I need to simulate the process OS detecting the device when is it connected to system thru USB port and loads a driver. OS should treat my application as a device and load its driver..plz any one help me out this .
|
|
|
|
|
hi ,
i have the following problems... would be gratefulif you could kindly give me some suggestions.....
1)i have a dialog based application in which i have to implement a scroll view .. can i use CSrollView(i suppose i cant)..if not how do i do it..if yes then how do i do it
2)i have to capture the entire image irrespective of being within the viewable region or not ....how do i go about it....
plesae help...
Thanking you.
Satadru
|
|
|
|
|
1) to use Views in a Dialog there is a splended article in MSDN with sample code that should help
( but i can't figure out why you have to use CScrollView it doesn't provide anything else other than scrolling support
you can use scroll bars on the dialog instead)
2)if that image is not completely displayed than you cannot capture it (it would be like , you give the application ur DC and ask it to paint on it )
but you can try to get that window's DC and Bitblt (might work)
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
hi ,
thanks for the help cud u please tell me which article is that.... i have another problem..
from my main dialog iam creating another dialog and popping it....from this second dialog i have to access members of the main dlg ... how do i go about it ... i have tried DYNAMIC_DOWNCAST but it isnt working in my compiler ... any way ouy...
Thanking you.
Satadru
|
|
|
|