|
Cheers Mark, that was very helpful. Thanks for your time
|
|
|
|
|
Hie,
I have one function
void Log(const string& format="", ...)
{
va_list args;
va_start(args,format);
int len= vsprintf(buffer, format, args);
va_end(args);
cout<
|
|
|
|
|
vikrams wrote: vsprintf(buffer, format, args);
Maybe you are passing a invalid format string. If it's not a valid format string then the behavior is undefined.
Maybe you can modify the above function to look like this...
void __cdecl Log( const char* lpszString, ... )
{
va_list args;
va_start(args, lpszString );
int len = vsprintf(buffer, lpszString, args );
va_end(args);
}
And what is this buffer variable??
|
|
|
|
|
I tried using format.c_str().
but it's crashing.
|
|
|
|
|
please Vikrams you start to know CP well enough nowadays to know that you should post code samples within <pre></pre> html tags...
see my sig for a relevant link
|
|
|
|
|
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
|
|
|
|