|
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.
|
|
|
|
|
Hello
Does anyone know of a way to use AnimateWindow() to fade out a window without blocking at all. If I use the sugested param of 200 ms my application feels unresponsive as the main thread is blocked. The documentation says I cannot call this on a window owned by another thread so I cant spawn off a thread to do it
|
|
|
|
|
I'm experiencing a very weird bug that I can't determine the source of. My only clue are some windows errors which shouldn't be occuring. And I don't just mean I think everything is set up so they shouldn't be occuring, I mean that between when I call SetLastError(0) and GetLastError() I'm not even calling any code that is capable of triggering them. The only explanation I could think of is that my program is somehow corrupting itself, but I've looked through my code carefully and I don't see how. Plus, the VC++ debugger isn't reporting and out of bounds memory access, buffer overuns, or anything else for that matter. I'd like to know if it's possible to set up VC++ to break on a windows error so I can find out excactly where the errors are coming from and why, without having to put a GetLastError() between every line of code.
|
|
|
|
|
Hello all,
I have a question on about how to prevent to prevent the memory leak? I am writing a window program, and I have an Assert() so that if any fatal erorr occured, the Assert() will call
Sleep(INFIITE) to stop the program, and print out the error message to the user. By doing that, the only way to exit the program after Assert() has been called is to close the window. However, it causes a problem which is that even though the desturctor of each classes in the program will be called when the user close the window, there may still some memory leak in the local scoop when I use Assert() like this, eg in funciton f()
f() {
char* name = new char[10];
Assert(AnyError(), "Fatal Error!");
strcpy(name, "Hello");
delete [] name;
}
For example, if I get the Assert() if I get any error in f(), then when the user close the window, I will have a memory leak for 10 bytes. What is the best way to solve the problem? I don't want to use the try and catch block since the code will be mess up with all those try and catch block. And I really want to stop the program when the fatal error occurs. Any ideas? Thanks!
Nacho
|
|
|
|
|
Im not sure i fully understand.
If you program has hit a fatal error and is exiting then you could probably not worry and rely on the OS to clean up after you.
Perhaps you could use a smart pointer
A smart pointer is usually a template class that pretends to be a pointer by providing the -> and * operators.
Because the smart pointer itself is on the stack its destructor will be called and you can delete the memory then.
I think the stl has a smart ptr template. You might want to start there
However if your Assert() function never returns then that wont work either.
Why dont you throw an exception in your Assert() function and catch it at a higher level
Good luck
|
|
|
|