|
Hi baerten,
I agree with Luc. However you may be able to use a pre-defined macro[^] something like below:
VOID FunctionB(int iVal,char *caller,int line)
{
char szBuf[MAX_PATH];
sprintf(szBuf,"I was called by %s on line %d",caller,line);
MessageBoxA(NULL,szBuf,0,0);
}
VOID FunctionA()
{
FunctionB(1,__FUNCTION__,__LINE__);
}
baerten wrote: i can't write over 100 Debug-Lines into the code
A stack trace is several times more expensive at runtime.
Best Wishes,
-David Delaune
|
|
|
|
|
You need a stack walking function. Here are some[^] links[^] that may be useful.
The second is probably best - John Robbins is a well regarded expert on debugging and things like that. His SUPERASSERT code includes stack tracing code - see the dialog screenshot about half way through the article for an example of what you can get. Obviously you only need the last item in the trace.
One last thing - IIRC, without debug symbols, all you're going to get is the address that called you, not a function name.
|
|
|
|
|
Hi,
I want to perform basic operations on database like add,update,delete using VS2005 and SQLServer 2005.
Which are the set of functions to work with this?
Please suggest any useful link to start with.
Thanks in advance.
R.
|
|
|
|
|
|
Thanks Rahul for your help.
|
|
|
|
|
You can use of CDatabase class and see this[^] example.
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 )
|
|
|
|
|
Thanks Hamid for ur help. Can you plz tell me how can i find sample for ODBC with VC++?
|
|
|
|
|
Hi All,
This query is regarding memory issue on WinXP (SP2). I have a simple application developed on MSVS2005 IDE. I am observing a peculiar behaviour of this application's memory usage when run on XP(SP2) machine:
Internally i make use of the COM interface to access the database - MSADO.
1. WinXP(SP2 with WLAN API patch) - Memory usage around 9Mb
2. WinXP(Microsoft IDE 2005 with SP2 with WLAN API patch) - Memory usage around 26Mb
Do anyone have any idea behid this dire memory consumption when the application is run on XP with Visual Studio being installed.
Thanks in advance for your time and support...
Sunil
|
|
|
|
|
Some questions - - Is this a debug or release build
- Are you running the application under VS2005 when you get the 26MB memory usage
Maybe you could use Dependency Walker[^] to see what DLLs are being loaded into the executable, maybe some of them are Visual Studio related?
|
|
|
|
|
Hi Sunil,
Microsoft Windows will map many extra DLL's into your process space which do not appear in a PE image dependency walker. These extra libraries which are mapped into your process can be completely different on each users machine.
Some examples of extra dynamic link libraries which could be mapped into your process:
1.) AppInit_DLLs[^]
2.) Window Hooks[^]
3.) Application Compatibility Layer[^] (Much of the AppCompat/Shim Engine is NDA undocumented)
4.) Device Drivers may map extra DLL's into a process.
If you want to visually inspect which libraries are loaded in each situation then I would recommend downloading Process Explorer by Mark Russinovich[^]. You can export your process information to a text file and differentiate them.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi all,
I have made a Report style List control in my Dialog based application. I have two columns and I want to compare first column value with second column value i.e it will perform a linear search for comparing items. My problem is sometimes my list has thousands of item so it takes very long time for doing so.... my second list items are sorted.....
Can anybody tell me how to reduce searching time and make my program run faster.....
Thanks in advance......
|
|
|
|
|
- I would (pretty much always) hold the data separate from the list control (using the LVS_OWNERDATA[^] style). That way you compare data using some container (STL rather than MFC, please, for me) which will be much quicker than by putting the data in the list control.
- As the second column is sorted, you can search through it using a binary search[^], which the STL has built-in....although you want to use lower_bound[^] rather than the more obvious binary_search[^]
HTH!
|
|
|
|
|
Hi,
I'm c++ beginner.
Can you help me,
because I dont know how to "specify the path"
of the text file i want to access.
thanks.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
// "path of input.txt"
ifstream iFile("input.txt");
while (!iFile.eof())
{
int x;
iFile >> x;
cerr << x << endl;
}
return 0;
}
|
|
|
|
|
What's your problem exactly ? Just pass the path to your file to the ifstream constructor. Be carefull when passing the character '\', you'll need to escape it (e.g. something like this "folder1\\folder2\\myFile.txt").
If you are using relative path, you need to take care of your working directory. The working directory is configured through your project options.
|
|
|
|
|
because I want to add exact path in the code just like in
vb command "Open Path & Filename For Input As #1"
thanks
|
|
|
|
|
Err sorry, I have no idea what "Open Path & Filename For Input As #1" does.
What do you mean by exact path ? Did you try my suggestion ?
|
|
|
|
|
yes, i can read/access the txtfile,
but i want to try to specify the path in code itself.
example.
in code there is a msg
"pls input the directory or path where you save the file"
thanks again.
|
|
|
|
|
Sorry, but you will need to be much more explicit because I'm lost.
mac_g wrote: but i want to try to specify the path in code itself.
That was what I explained you: just pass a string which contains the path.
mac_g wrote: in code there is a msg
"pls input the directory or path where you save the file"
In code ? You mean you display that message on the console and wait until the user type the path ? If yes, just retrieve the string he typed and pass it to the ifstream constructor, that's as easy as that.
So, where are you stuck exactly ? In the part where you have to retrieve the string from the user or passing the string to the constructor ?
Please also explain what you already did and what is the exact problem you encounter.
|
|
|
|
|
can you give me an example for retrieving the string to the ifstream constructor?
thanks
|
|
|
|
|
Do you mean like this:
ifstream iFile("c:\\SomeDirectory\\AnotherDirectory\\input.txt");
or maybe you want the path in a separate variable and you want to add the filename onto the path?
#include <shlwapi.h>
void UseFile(const char* directory)
{
char path[MAX_PATH];
PathCombine(path, directory, "input.txt");
ifstream iFile(path);
The Boost FileSystem[^] library is another way of doing that - that will become part of the C++ standard libraries sometime in the future.
|
|
|
|
|
yes..thank you...
|
|
|
|
|
Hi all,
Is it possible to convert an String which is identical to an enum symbol to an enum value?
Currently I am converting an string _T("ONE") into an enum symbol ONE using string comparison as indicated by the code snippet below.
in a .h file
enum
{
ZERO = 0,
ONE,
TWO,
THREE
};
{
int myenum = 0;
TCHAR szNumber[MAX_PATH]={0};
_tcscpy(szNumber, _T("ONE"));
ConvertStrtoEnum(szEnum, myenum)
}
static void ConvertStrtoEnum(TCHAR &szEnum, int myenum)
{
if(!_tcscmp(szEnum, _T("ZERO"))
myenum = ZERO;
else if(!_tcscmp(szEnum, _T("ONE"))
myenum = ONE;
.
.
.
return;
}
is there another alternative to achieving the same result?
Any guidance will be helpful.
Regards.
|
|
|
|
|
No, you can't do that (not by a standard way anyway).
For what purpose do you need to have that mechanism ? In general , when you need to have something like that, it means something is wrong with your design (but it's not true in all cases)...
|
|
|
|
|
The application that I am developing reads data (one of the data is of type enum)from the xml.
Rather than having numbers in the xml file, I wanted to include the enum symbols itself(strings) which is readable and self explainatery in the xml file.
It is left to my application to read the strings and convert it to the corresponding enum value.
Is there any alternative approach to this? (the other apporach being mention the enum value in the xml itself)
|
|
|
|
|
Comp_Users wrote: Rather than having numbers in the xml file, I wanted to include the enum symbols itself(strings) which is readable and self explainatery in the xml file.
Honnestly, in this specific case, I don't really agree with you: writing ZERO instead of 0 in the xml file doesn't make it clearer. If it is a number, why do you want to write it as a string ? Well, it's just my opinion...
|
|
|
|