OutputDebugString下遇见了LPCSTR与char *str之间的关系

CCC.h

 1 #pragma once
 2 
 3 #include <windows.h>
 4 
 5 typedef LPCSTR XXX;
 6 
 7 class CCC
 8 {
 9 public:
10     void OPSID(XXX lpstr1,XXX lpstr2)
11     {
12         OutputDebugString(lpstr1);
13         OutputDebugString(lpstr2);
14     }
15 protected:
16 private:
17 };

DDD.h

 1 #pragma once
 2 
 3 #include <windows.h>
 4 
 5 typedef const char *xLPCSTR,*xPCSTR;
 6 
 7 class DDD
 8 {
 9 public:
10     void OPSID(xLPCSTR lpstr1,xLPCSTR lpstr2)
11     {
12         OutputDebugString(lpstr1);
13         OutputDebugString(lpstr2);
14     }
15 protected:
16 private:
17 };

应用以上代码

1   char strArray[256]="12313";
2     CCC *pccc;
3     pccc=new CCC();
4     pccc->OPSID("",strArray);
5 
6     DDD ddd;
7     ddd.OPSID(strArray,strArray);

LPCSTR 、 const char * 、怎么输出字符串到缓冲区 、printf(char*,const char* ......)

所有的事实都在说明const char * 能干的事情一目了然

posted on 2014-04-21 00:01  谢致远  阅读(482)  评论(0)    收藏  举报

导航