原来指针也可以这样用啊

这两天我真疯掉了,主要是学习的原因.从来没有感觉指针还可以这样用.哎以后的好好看书了.

struct strpt

{

char a:1;

char b:2;

char c:4;

char d:2;

};

 

int a = 12;

strpt* pt = (strpt*)&a;

哎.....看来还的加强学习.

不过我的能令vc2005编译器崩溃的程序还是让我自豪万分.

错误提示:
1>e:\workspace\temppointer\temppointer\1.cpp(42) : fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'f:\rtm\vctools\compiler\utc\src\P2\ehexcept.c', line 977)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
1>Please choose the Technical Support command on the Visual C++
1> Help menu, or open the Technical Support help file for more information

我的原代码是:
#include <afx.h>
#include <iostream>

using namespace std;

// 求二维数组中某一维的成员个数
int funC(CString temp[]);

int main()
{
 CString ss[][12] =
 {
  {"sd","fsffs","fsfs","2333",""},
  {"12345","1234566789","sss"},
  ""
 };
 int k = funC(ss[0]);
 cout<<"k is: "<<k<<endl;

 return 0;
 
}


int funC(CString temp[])
{
 int k = 0;// 成员个数


 CString* pt = temp;
 
 while ( !(pt->IsEmpty()) && (k<12) )
 {
  pt++;
  k++;
 }


 return k;
}

 

什么原因我已经知道了.不过这样的程序好玩

posted on 2010-06-03 00:17  carekee  阅读(373)  评论(0编辑  收藏  举报