随笔分类 -  00.C/C++

摘要:#include <windows.h>#include <iostream>using namespace std;DWORD WINAPI MyThreadProc1(LPVOID lpParameter); //thread dataDWORD WINAPI MyThreadProc2(LPVOID lpParameter);DWORD WINAPI MyThreadProc3(LPVOID); //thread dataDWORD WINAPI MyThreadProc4(LPVOID);int tickets=100;HANDLE hMutex;int mai 阅读全文
posted @ 2012-03-23 18:30 庚武 阅读(233) 评论(0) 推荐(0)
摘要:#include <iostream>using namespace std;class A{public: int m_a; A(int a):m_a(a){ cout<<"A 构造"<<endl; } void introA(){ cout<<"m_a:"<<m_a<<endl; }};class B1:public A{public: int m_b1; B1(int a,int b1):A(a),m_b1(b1){ cout<<"B1 构造"& 阅读全文
posted @ 2012-03-23 01:01 庚武 阅读(335) 评论(0) 推荐(0)
摘要:void CMenuView::OnRButtonDown(UINT nFlags, CPoint point) { //弹出菜单 /* CMenu menu; menu.LoadMenu(IDR_MENU_POPUP); CMenu *pMenu = menu.GetSubMenu(0); //ScreenToClient(&point); ClientToScreen(&point); pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,this); */ CView::OnR 阅读全文
posted @ 2012-03-17 12:34 庚武 阅读(795) 评论(0) 推荐(0)
摘要:// crt_sprintf.c// compile with: /W3// This program uses sprintf to format various// data and place them in the string named buffer.#include <stdio.h>int main( void ){ char buffer[200], s[] = "computer", c = 'l'; int i = 35, j; float fp = 1.7320534f; // Format and print vario 阅读全文
posted @ 2012-03-16 15:47 庚武 阅读(843) 评论(0) 推荐(0)
摘要://filename:VisualKB.h#define MAX_STRING 12class CMyApp:public CWinApp{public: virtual BOOL InitInstance();};class CMainWindow:public CWnd{protected: int m_cxChar; //Average character width int m_cyChar; //Character height int m_cyLine; //Vertical line spacing in message box int m_nTextPos; ... 阅读全文
posted @ 2012-03-02 14:38 庚武 阅读(595) 评论(0) 推荐(0)
摘要:学习C语言可变参数时,发现#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )乍一看,完全不明白该宏的作用是啥,仔细分析后发现,该宏是求类型n是整型int的多少倍(向上取整).在32位win中,siz... 阅读全文
posted @ 2012-02-26 03:08 庚武 阅读(949) 评论(0) 推荐(0)
摘要:#include <windef.h> //Basic Type Definitions#include <winnt.h> //Definitions for Unicode support#include <winbase.h> // Kernel functions#include <wingdi.h> //Graphic Device Interface functions#include <winuser.h> //User Interface functions 阅读全文
posted @ 2012-02-22 17:08 庚武 阅读(672) 评论(0) 推荐(0)
摘要:在VC6中创建一个MFC Dialog工程,下面是创建Unicode版本的操作步骤:1.Build-->Configurations-->Add,添加一个Unicode Debug配置;2.Build-->Set Active Configuration,选择Win32 Unicode Debug作为当前活动配置;3.在Project-->Settings,在C/C++属性页中选择Preprocessor条目,在Preprocessor definitions中添加编译项 _UNICODE;如果此时就编译,就会立生错误:msvcrtd.lib(crtexew.obj) 阅读全文
posted @ 2012-02-21 11:58 庚武 阅读(831) 评论(0) 推荐(0)
摘要:1.在MFC中加入TRACE语句2.在TOOLS->MFC TRACER中选择 “ENABLE TRACING”点击OK3.进行调试运行,GO(F5)(特别注意:不是执行‘!’以前之所以不能看到TRACE内容,是因为不是调试执行,而是‘!’了,切记,切记)4.然后就会在OUTPUT中的DEBUG窗口中看到TRACE内容了,调试执行会自动从BUILD窗口跳到DEBUG窗口#include <iostream>#include <afxwin.h>using namespace std;int main(){ cout<<("Hello 中国&q 阅读全文
posted @ 2012-02-20 17:56 庚武 阅读(1707) 评论(0) 推荐(0)
摘要:http://msdn.microsoft.com/en-us/library/azz5wt61(v=vs.80).aspxA device context is a Windows data structure containing information about the drawing attributes of a device such as a display or a printer. All drawing calls are made through a device-context object, which encapsulates the Windows APIs f 阅读全文
posted @ 2012-02-18 20:35 庚武 阅读(741) 评论(0) 推荐(0)
摘要://filename:Hello.hclass CMyApp:public CWinApp{public: virtual BOOL InitInstance();};class CMainWindow:public CFrameWnd{public: CMainWindow();protected: afx_msg void OnPaint(); afx_msg void OnLButtonDown( UINT nFlags, CPoint point ); DECLARE_MESSAGE_MAP()};//filename:Hello.cpp#include <afxwin.h> 阅读全文
posted @ 2012-02-18 19:13 庚武 阅读(204) 评论(0) 推荐(0)
摘要:#include <iostream>using namespace std;class P{public: P * m_p; P(){ this->m_p=this; } virtual void Intro(){ cout<<"this is P"<<endl; }};class S:public P{public : virtual void Intro(){ cout<<"this is S"<<endl; }};S s;int main(){ s.Intro(); s.m_p-& 阅读全文
posted @ 2012-02-18 13:44 庚武 阅读(198) 评论(0) 推荐(0)
摘要:#include <windows.h>#include <stdio.h>LONG WINAPI WndProc(HWND, UINT,WPARAM,LPARAM); //回调原型int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ){ WNDCLASS wc; HWND hwnd; MSG msg; //1.设计窗体 //wc... 阅读全文
posted @ 2012-02-16 01:50 庚武 阅读(197) 评论(0) 推荐(0)
摘要:#include <windows.h>LONG WINAPI WndProc(HWND, UINT,WPARAM,LPARAM); //回调原型int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ){ WNDCLASS wc; HWND hwnd; MSG msg; //1.设计窗体 wc.style = 0; wc.lpfnW... 阅读全文
posted @ 2012-02-16 00:48 庚武 阅读(456) 评论(0) 推荐(0)
摘要:http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml 阅读全文
posted @ 2012-02-07 09:51 庚武 阅读(157) 评论(0) 推荐(0)
摘要:from:http://blog.csdn.net/liquanhai/article/details/7215045过年了,事情可以暂时放一下了。总结一下很有必要。又看到外面饭馆写着“岁末收工,初六开炉“了。好了,废话不多说,接着上篇继续评点程序员常用工具。当然还得请朋友们留言,好做继续的整理和补充,谢谢!顺祝大家新年好!文中已经提供每个工具的超链接地址,请点击下载:1. IDE:钟情于VC++6.0,但是也感觉Visual Studio2008和2010的强大,可能迟早得转到VS高版本上来。在安装VC++6.0的时候记得安装sp6补丁和msdn(MSDN_1.5_精简安装版)2. 辅助:( 阅读全文
posted @ 2012-01-29 20:43 庚武 阅读(273) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <stdlib.h>#include <ctype.h>int main(){ printf("Hello world!\n"); char ch[100]="hEll,O!@#$!@#$!@St4465456ri45656ngIKLSDJFLsdkjfsdiwerjdskfjsd"; char *pc=ch; printf("处理前:%s\n",ch); for(;*pc!='\0';pc++){ if(isalpha(*pc) 阅读全文
posted @ 2012-01-12 10:49 庚武 阅读(406) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <stdlib.h>#define NUM_LEN 100int add_str(char * pch1,char * pch2 , char * chResult){ chResult[NUM_LEN-1]='\0'; int idx=NUM_LEN-2; char *pEnd1=pch1,*pEnd2=pch2; for(;*pEnd1!='\0';pEnd1++); for(;*pEnd2!='\0';pEnd2++); pEnd1--; pEnd2--; sho 阅读全文
posted @ 2011-12-02 13:41 庚武 阅读(1460) 评论(0) 推荐(0)
摘要:#pragma pack(push)#pragma pack(4)typedef struct { double d1; int member; char ch; int member2;}s_member;#pragma pack(pop) sizeof(s_member): 20VC,GCC都支持 阅读全文
posted @ 2011-12-01 10:54 庚武 阅读(165) 评论(0) 推荐(0)
摘要:from:http://zh.wikipedia.org/zh-hk/C和C%2B%2B運算子以下是C++程式語言中的所有運算子的優先級和結合性列表。優先級運算子敘述示例重載性結合性1::作用域解析(C++專有)Class::age = 2;否由左至右2++後綴遞增i++--後綴遞減i--{}組合{i++;a*=i;}()函數調用或變量初始化c_tor(int x, int y): _x(x), _y(y * 10) {}[]數組訪問array[4] = 2;.以對象方式訪問成員obj.age = 34;否->以指針方式訪問成員ptr->age = 34;dynamic_cast運 阅读全文
posted @ 2011-12-01 00:50 庚武 阅读(608) 评论(0) 推荐(0)