|
To add to Nibu , uninitialized buffer could be causing crash.
Can you show , how it is declared ?
|
|
|
|
|
void Log(const string& format="", ...)
{
char buffer[1024]="";
va_list args;
va_start(args,format);
int len= vsprintf(buffer, format.c_str(), args);
va_end(args);
cout<<buffer;
}
This is not working !
|
|
|
|
|
This code runs without any crash.
|
|
|
|
|
vikrams wrote: This is not working !
With what input?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
vikrams wrote: This is not working !
When using a string type, va_start() adds 16 bytes to the starting address of format to get to the first optional argument. However, when using format.c_str() with vsprintf() , you are not 16 bytes from the start of format .
Try this instead:
void Log(const char *format, ...)
{
char buffer[1024] = "";
va_list args;
va_start(args, format);
int len= vsprintf(buffer, format, args);
va_end(args);
cout<<buffer<<endl;
}
...
Log(fmt.c_str(), "Hello World");
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'd use the Boost.Format[^] library to do this kind of thing.
Steve
|
|
|
|
|
I am programming with strings and i got this error when i am trying to upgrade my code from VC6.0 to VC7.1 . Its very urgent can anybody help me please.
regards,
venkat.
Uday kiran
|
|
|
|
|
|
Which identifier is not found ? Your post is lacking of relevant information.
Identifier not found probably means that you forgot to include a header file.
|
|
|
|
|
uday kiran janaswamy wrote: I am programming with strings
I think it's not _L but _T .
|
|
|
|
|
Hi all,
do we have some way by which we can have a function
with which we can do the cleanup job!!
like exit handler for threads.
i have created thread with CreateThread
Thanks
Harshal
|
|
|
|
|
You can call any function you have access to from your thread.
Write a cleanup function and call it?
Are you thinking along the lines of InitInstance/ExitInstance virtual initialization/cleanup
methods?
|
|
|
|
|
hello
can we have a toolbar on dialog ???
|
|
|
|
|
have you had a look here[^] ?
|
|
|
|
|
cancerion wrote: can we have a toolbar on dialog ???
Take a look at CWnd::RepositionBars . MSDN has a nice sample on this too.
For the sample you will have to search MSDN with the keyword as RepositionBars .
|
|
|
|
|
Yes and you can see examples on codeproject
|
|
|
|
|
|
please delete this post...
instead of reposting when you've done a mistake, do you know there's an "Modify" link at the bottom-right of your messages, so that you can edit them without rewrite it all ?
|
|
|
|
|
can any body tell me in solving the compilation and execution problem of the download sample from the page mentioned here --> http://www.codeproject.com/system/RemoveDriveByLetter.asp[^]
i have copied cfgmgr32.h file from web and added to the project.
please send me the clear description how this problem can be executed properly.
Madhukar Charla
|
|
|
|
|
hello,
I'm about to integrate the DDK in Visual C++. I found two batch files, which should do this:
http://www.hollistech.com/Resources/ddkbuild/ddkbuild.htm
http://www.osronline.com/article.cfm?article=43
but I was unable to make this work.
so I beg you to help me with this. or is there a solution without these files ?
thank you a lot, TSX
|
|
|
|
|
Hi all.
I have a bmp image and i have set it as a back ground of a dialog box. But the controls on dialog box are not getting matched with the colors from image. I mean the background of various controls like check box, radio button, static controls, etc is typical system color, i.e. off brown.
I can set the background color of the controls by overriding OnCtlColor() of CDialog class. But to set their backgound, I need the color from image, and as image is having number of colors I can't go with one perticular color?
My question is how I can make back ground colors of the controls exactly same as that of image color on which I have dropped them?
Thanks
Rakesh Thakur
|
|
|
|
|
Do you want to write text on an image?
|
|
|
|
|
|
I have been racking my brains to figure out how to detect a modal dialog box coming up and to response to the dialog box by lines of code which simulating "press ENTER key " or "clicking a button".
In my project, I import a dynamically linked library to use some functions. One function bring up some modal dialog boxes, suspending the main thread. I want to responsing to the dialog box as soon as it pops up by simulating the act of "Pressing the OK button on the dialog" with code. On the dialog box, there is only a OK button(having focus). Currently, I have to press the OK button manually whenever a dialog box comes up. I think the solution involves two aspects: (1) detect the occurrence of a dialog box; (2) simulate "Pressing the OK button on the dialog" with code.
Can anyone help please. Without a solution, I have to reponse manually to handreds of thousands of dialog boxes to keep my program running.
By the way, there is no way I contact the authors of the dynamically linked library to solve this problem.
|
|
|
|
|
One solution would be,
Get handle to that dialog, (using FindWindow() , you could use timer for this).
And then use SendMessage(WM_CLOSE,..) .
i.e.
void MyTimerProc(LPVOID)
{
HWND hDlg = FindWinow(NULL,_T("Dialog Title"));
SendMessage(hDlg,WM_CLOSE,0,0)
}
|
|
|
|