|
|
Hi
Perhaps I'm wrong but INT_MAX is defined as maximum int value 2^31-1
What I need is maximum array size for type int
Is constant INT_MAX also used to define maximum array size for type int?
Tomaz Rotovnik
|
|
|
|
|
|
I need an huge array and I want prevent application crash.
I think I found the answer:
max heap size is declared in malloc.h
/* Maximum heap request the heap manager will attempt */
#define _HEAP_MAXREQ 0xFFFFFFE0
Tomaz Rotovnik
|
|
|
|
|
Tomaz Rotovnik wrote:
#define _HEAP_MAXREQ 0xFFFFFFE0
That is 4GB, a lot more memory that most computers have...
If you use malloc to alloc your array, the app will not crash, but you will get a NULL pointer if it fails.
- Anders
Money talks, but all mine ever says is "Goodbye!"
ShotKeeper, my Photo Album / Organizer Application
[^]
My Photos[^]
|
|
|
|
|
Anders Molin wrote:
That is 4GB, a lot more memory that most computers have...
Even if the computer had 8GB of RAM, the memory manager only allows each process 2GB for its address space, or 3GB if the /3GB startup switch were used.
Anders Molin wrote:
...if it fails.
That should be "when it fails."
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi , I'm wondering if anyone can help me out with this , or steer me in the right direction.
I get these errors , when trying to compile..
--
C:\phonebook.cpp(71) : error C2593: 'operator >>' is ambiguous
C:\phonebook.cpp(72) : error C2593: 'operator <<' is ambiguous
C:\phonebook.cpp(73) : error C2593: 'operator <<' is ambiguous
--
<br />
#include iostream
#include fstream<br />
#include cstring<br />
<br />
using namespace std;<br />
<br />
class phonebook {<br />
public:<br />
char name[80];<br />
char areacode[4];<br />
char prefix[4];<br />
char num[5];<br />
phonebook() { };<br />
phonebook(char *n, char *a, char *p, char *nm)<br />
{<br />
strcpy(name,n);<br />
strcpy(areacode,a);<br />
strcpy(prefix,p);<br />
strcpy(num,nm);<br />
}<br />
friend ostream &operator<<(ostream &stream, phonebook o);<br />
friend istream &operator>>(istream &stream, phonebook &o);<br />
};<br />
<br />
ostream &operator<<(ostream &stream, phonebook o)<br />
{<br />
stream << o.name << "\t";<br />
stream << "(" << o.areacode << ") ";<br />
stream << o.prefix << "-";<br />
stream << o.num << "\n";<br />
return stream;<br />
}<br />
<br />
istream &operator>>(istream &stream, phonebook &o)<br />
{<br />
cout << "Enter name: ";<br />
stream >> o.name;<br />
cout << "Enter area code: ";<br />
stream >> o.areacode;<br />
cout << "Enter prefix: ";<br />
stream >> o.prefix;<br />
cout << "Enter number: ";<br />
stream >> o.num;<br />
cout << "\n";<br />
return stream;<br />
}<br />
<br />
bool main (void)<br />
{<br />
phonebook a;<br />
char c;<br />
fstream pb("phone", ios::in | ios::out | ios::app);<br />
<br />
if(!pb) {<br />
cout << "Cannot open phone book file.\n";<br />
return false;<br />
}<br />
<br />
for(;;) {<br />
do {<br />
cout << "1. Enter numbers\n";<br />
cout << "2. Display numbers\n";<br />
cout << "3. Quit\n";<br />
cout << "\nEnter a choice: ";<br />
cin >> c;<br />
} while(c<'1' || c>'3');<br />
<br />
switch(c) {<br />
case '1':<br />
<br />
cin >> a;<br />
cout << "Entry is: " << a;<br />
pb << a;<br />
break;<br />
<br />
case '2':<br />
<br />
char ch;<br />
pb.seekg(0, ios::beg);<br />
while(!pb.eof()) {<br />
pb.get(ch);<br />
if(!pb.eof()) cout << ch;<br />
}<br />
pb.clear();<br />
cout << endl;<br />
break;<br />
<br />
case '3':<br />
<br />
pb.close();<br />
return false;<br />
<br />
}<br />
<br />
}<br />
return true;<br />
}<br />
it seems to have trouble around here.
--
cin >> a;
cout << "Entry is: " << a;
pb << a;
--
any help ,or comments would be greatly appreciated.
Thanks..
Note: this code is originally from "The Complete Reference, C++ Fourth Edition" , a book I've been studying..
|
|
|
|
|
Include the .h files ( iostream.h etc...)
ane remove the using namespace statement.
Think it'll compile.
|
|
|
|
|
I tried to use the SetProcessDefaultLayout() fuction of the platform sdk, but the compiler couldn't find it in the winuser.h header. I opened the header myself and I found that the fuction is declared as follows:
#if(WINVER >= 0x0500)
WINUSERAPI
BOOL
WINAPI
GetProcessDefaultLayout(
OUT DWORD *pdwDefaultLayout);
WINUSERAPI
BOOL
WINAPI
SetProcessDefaultLayout(
IN DWORD dwDefaultLayout);
#endif /* WINVER >= 0x0500 */
so what does WINVER>=0x0500 mean?
also the LAYOUT_RTL default layout is not defined in the header.
can any one help please? thanks in advance
|
|
|
|
|
|
i m working on video capture using VC++ n DirectShow
i change the configuration from Debug to Release ..
than there is a list of errors: i cant find its solution plz tell me .. thanx
camDlg.obj : error LNK2001: unresolved external symbol _MEDIATYPE_Audio
camDlg.obj : error LNK2001: unresolved external symbol _MEDIATYPE_Video
camDlg.obj : error LNK2001: unresolved external symbol _TIME_FORMAT_FRAME
camDlg.obj : error LNK2001: unresolved external symbol "int __cdecl wsprintfWInternal(unsigned short *,unsigned short const *,...)" (?wsprintfWInternal@@YAHPAGPBGZZ)
camDlg.obj : error LNK2001: unresolved external symbol _TIME_FORMAT_MEDIA_TIME
camDlg.obj : error LNK2001: unresolved external symbol _IID_IMediaControl
ReportDlg.obj : error LNK2001: unresolved external symbol _IID_IMediaControl
camDlg.obj : error LNK2001: unresolved external symbol _IID_IVideoWindow
ReportDlg.obj : error LNK2001: unresolved external symbol _IID_IVideoWindow
camDlg.obj : error LNK2001: unresolved external symbol _LOOK_UPSTREAM_ONLY
camDlg.obj : error LNK2001: unresolved external symbol _IID_IAMCrossbar
camDlg.obj : error LNK2001: unresolved external symbol _PIN_CATEGORY_CAPTURE
camDlg.obj : error LNK2001: unresolved external symbol _PIN_CATEGORY_PREVIEW
camDlg.obj : error LNK2001: unresolved external symbol _MEDIATYPE_Interleaved
camDlg.obj : error LNK2001: unresolved external symbol _CLSID_NullRenderer
camDlg.obj : error LNK2001: unresolved external symbol _PIN_CATEGORY_VIDEOPORT
camDlg.obj : error LNK2001: unresolved external symbol _CLSID_CaptureGraphBuilder2
camDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall CMediaType::~CMediaType(void)" (??1CMediaType@@QAE@XZ)
camDlg.obj : error LNK2001: unresolved external symbol "public: void __thiscall CMediaType::SetSubtype(struct _GUID const *)" (?SetSubtype@CMediaType@@QAEXPBU_GUID@@@Z)
camDlg.obj : error LNK2001: unresolved external symbol _MEDIASUBTYPE_RGB24
camDlg.obj : error LNK2001: unresolved external symbol "public: void __thiscall CMediaType::SetType(struct _GUID const *)" (?SetType@CMediaType@@QAEXPBU_GUID@@@Z)
camDlg.obj : error LNK2001: unresolved external symbol "public: __thiscall CMediaType::CMediaType(void)" (??0CMediaType@@QAE@XZ)
camDlg.obj : error LNK2001: unresolved external symbol _IID_IBaseFilter
camDlg.obj : error LNK2001: unresolved external symbol _CLSID_SampleGrabber
camDlg.obj : error LNK2001: unresolved external symbol _CLSID_FilterGraph
ReportDlg.obj : error LNK2001: unresolved external symbol _CLSID_FilterGraph
camDlg.obj : error LNK2001: unresolved external symbol _CLSID_VideoInputDeviceCategory
camDlg.obj : error LNK2001: unresolved external symbol _CLSID_SystemDeviceEnum
camDlg.obj : error LNK2001: unresolved external symbol _MEDIASUBTYPE_Asf
|
|
|
|
|
looks like missing .lib files in linker options
rrrado
|
|
|
|
|
Make sure your linker dependancies are set up the same way in both configurations. In VC++ .NET the option you need to look at is in the project properties page under linker and in input.
|
|
|
|
|
I added the lib files in link
now it giving warnings as follows
now wt should i do ?
Linking...
LINK : warning LNK4089: all references to "ADVAPI32.dll" discarded by /OPT:REF
LINK : warning LNK4089: all references to "OLEPRO32.DLL" discarded by /OPT:REF
LINK : warning LNK4089: all references to "WINMM.dll" discarded by /OPT:REF
cam.exe - 0 error(s), 3 warning(s)
|
|
|
|
|
I need to open dr watson's .wlg file created in win 98 after my application crashed. I've got .wlg file from the user, but I don't know how to open it.
Thanks !
rrrado
|
|
|
|
|
in the docs it is said that the SetProcessDefaultLayout()is found in windows.h and defined in winuser.h.
I included both files, and the compiler can't find the function.
I tried to open the winuser.h and I couldnot find the function.any help?
|
|
|
|
|
I would like to make an app that will not allow the user to execute any of the windows xp applications.
Does anybody know how to do that?
I try to do it by looking all the processes that are running and if there is any non system or any other necessary process, I terminate it with the TerminateProcess function.
The problem is when the user try to run the windows explorer. I can't see that process when it is running.
|
|
|
|
|
We try to avoid helping people write virus software. How about using the security built into XP and removing any NTFS permissions to the programs you don't want people using.
|
|
|
|
|
With the extern, can you use your own defined type to share global data or is it limited to int, bool float etc.
i.e.
struct
{
int x, y
float buff[10];
bool onOff;
}myStruct
extern myStruct g_myStruct1;
and how would you init the data.
|
|
|
|
|
1. Yes, but I'm sure you could've figured it out by trying it...
2. Globals are automatically inited to 0. Any other initializtions you may need to do could be accomplised by a special funtion you pass the structure to before you use it.
|
|
|
|
|
I though I understood extern but having second thoughts.
This is because sometimes get linker error if include extern in the global section of the main program.
i.e. they seem to work without using extern in the global section, but only use extern in units where you wish to use them.
e.g.
int g_nMyInt = 2;<br />
bool g_bMyflag = true;
Main()
and then use in the other unit:-
extern int g_nMyInt;<br />
extern bool g_bMyflag;
Wich is correct?
|
|
|
|
|
You only need externs in files where the global variables aren't already defined. Just keep that in mind and you shouldn't have any problems.
|
|
|
|
|
st to re-cap the following are both OK?
extern int g_nMyInt = 3;
extern CMyType g_Mystruct1; // Initialised by a routine at start-up
extern bool g_bMyFlag = true;
Main()
and
int g_nMyInt = 3;
CMyType g_Mystruct1; // Initialised by a routine at start-up
bool g_bMyFlag = true;
Main()
--------------------------------------------------------
and use in other units as required:-
extern int g_nMyInt;
extern CMyType g_Mystruct1; // Initialised by a routine at start-up
extern bool g_bMyFlag;
Many thanks.
Simple questions are sometimes not simple
|
|
|
|
|
You can't initialize an "extern" variable as you are in the first set. Otherwise, those are OK.
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
There is no guarantee that any variable, whether global or local, is initialised to 0. In a debug build, using VisualStudio, they do get initialised to 0, but that doesnt apply in a release build.
|
|
|
|