没有:
如何使用FormatMessage()
获取错误文本HRESULT
?
HRESULT hresult = application.CreateInstance("Excel.Application");
if (FAILED(hresult))
{
// what should i put here to obtain a human-readable
// description of the error?
exit (hresult);
}
Run Code Online (Sandbox Code Playgroud) 例:
# ddd --debugger /usr/bin/bashdb <sript-name> (on remote host)
Run Code Online (Sandbox Code Playgroud) 有效地在C++中进行命令行参数处理的建议:
注意:仅限Windows
1: #include <iostream.h>
2: int main(int argc, char **argv)
Run Code Online (Sandbox Code Playgroud)
而不是,例如:
if ( argc != 3 ) {
....
}
Run Code Online (Sandbox Code Playgroud)
问候
在Linux下用C编程时,我倾向于使用POSIX Threads.
没有MFC
题:
那么我如何在VC++中创建线程?
在win32下查找有关线程的更多信息?
我喜欢stackoverflow - 学生最好的资源!
问候
题:
如何显示值 a的C++ 迭代使用WinDbg的,示出如下:
for (vector<string>::iterator i = args.begin(); i != args.end(); i++)
//omitted
//for instance:
} else if (*i == "-i") {//attempting to display the value of *i
++i;
if (!::PathFileExistsA(i->c_str()))
{
Run Code Online (Sandbox Code Playgroud)
注意:
使用?? 评估C++表达式命令,它显示以下内容:
0:000> ?? i
class std::_Vector_iterator<std::basic_string<char,
std::char_traits<char>,
std::allocator<char> >,
std::allocator<std::basic_string<char,
std::char_traits<char>,
std::allocator<char> > > >
+0x000 _Mycont : 0x0012ff40 std::_Container_base_secure
+0x004 _Mynextiter : (null)
+0x008 _Myptr : 0x009c6198
std::basic_string<char,std::char_traits<char>,std::allocator<char> >
Run Code Online (Sandbox Code Playgroud)
*i
- 如果我错了,请纠正我#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define GIGABYTE 1024*1024*1024
int
main (void)
{
void *foo;
int result;
foo = (void *) malloc (GIGABYTE*5);
result = errno;
if (foo != NULL) {
return 2;
} else {
fprintf (stderr, "ERROR: %d\n", result);
return 1;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
# gdb -silent ./huge_malloc
)来停止/暂停执行,如果malloc()
回报率0x0
,没有检查是否foo
是0x0
注意:
题:
插图:
IS8Simulation *pis8 = NULL;
...
CoCreateInstance(
clsid,
NULL,
CLSCTX_LOCAL_SERVER,
__uuidof(IS8Simulation),
(void **) &pis8);
...
hThread = CreateThread(
NULL,
0,
SecondaryThread,
//interface pointer pis8
0,
&dwGenericThreadID);
...
DWORD WINAPI SecondaryThread(LPVOID iValue)
{
//using iValue accordingly
//E.g.: iValue->Open
Run Code Online (Sandbox Code Playgroud)
问候
更新 -你们都给了我一些见解,非常感谢你们
注意:
/*
* Trivial code
*/
wchar_t *greeting = L"Hello World!";
char *greeting_ = "Hello World!";
Run Code Online (Sandbox Code Playgroud)
WinDbg的:
0:000> ?? greeting
wchar_t * 0x00415810
"Hello World!"
0:000> ?? greeting_
char * 0x00415800
"Hello World!"
0:000> db 0x00415800
00415800 48 65 6c 6c 6f 20 57 6f-72 6c 64 21 00 00 00 00 Hello World!....
00415810 48 00 65 00 6c 00 6c 00-6f 00 20 00 57 00 6f 00 H.e.l.l.o. .W.o.
00415820 72 00 6c 00 64 00 21 …
Run Code Online (Sandbox Code Playgroud)