摘要:
#include <stdio.h>
#include <string.h>
struct TStudent
{ long int ID; union{ char name[10]; char mingzi[11]; }; char dept[17];
};
int main()
{ TStudent stu; strcpy(stu.name,"zh"); strcpy(stu.dept,"computer science"); printf("student`s mingzi is:%s\n",stu.min 阅读全文
posted @ 2011-07-08 23:20
程序员新鲜事
阅读(145)
评论(0)
推荐(0)
摘要:
代码:#include <stdio.h>
char* GetString1()
{ char p[] = "Hello World"; return p;
}
char* GetString2()
{ char *p = "Hello World"; return p;
}
int main()
{ printf("GetString1 returns: %s. \n", GetString1()); printf("GetString2 returns: %s. \n", GetString2()) 阅读全文
posted @ 2011-07-08 21:45
程序员新鲜事
阅读(161)
评论(0)
推荐(0)
摘要:
代码:#include <stdio.h>
int main()
{ int a=0,b=0; printf("%d\n",!a||++b||b++); printf("b=%d\n",b); printf("%d\n",!a&&++b&&b++); printf("b=%d\n",b); return 0;
}疑:以上输出什么,为什么?解答:int a=0,b=0;在在第一次printf语句中,!a为1,后面的++b和b++就不做了,所以第二次输出是0,第三次print 阅读全文
posted @ 2011-07-08 21:42
程序员新鲜事
阅读(124)
评论(0)
推荐(0)
摘要:
代码:#include <iostream>
using namespace std;
class A
{
public: A() { Print(); } virtual void Print() { cout<<"A is constructed.\n"; }
}; class B: public A
{
public: B() { Print(); } virtual void Print() { cout<<"B is constructed.\n"; }
}; int main()
{ A* p... 阅读全文
posted @ 2011-07-08 21:39
程序员新鲜事
阅读(179)
评论(0)
推荐(0)
摘要:
代码:头文件print_tools.h#include<stdio.h>
void printStr(const char *pStr)
{ printf("%s\n",pStr);
}
void printtInt(const int i)
{ printf("%d\n",i);
}
头文件counter.h#include"print_tools.h"
static int sg_value;
void counter_init()
{ sg_value=0;
}
void counter_count()
{ sg_v 阅读全文
posted @ 2011-07-08 21:15
程序员新鲜事
阅读(179)
评论(0)
推荐(0)
摘要:
代码:#include<iostream>
using namespace std; class A
{
private: int value;
public: A() { value=0; } void coutHello() { cout<<"hello"<<endl; } void coutValue() { cout<<value<<endl; }
};
int main()
{ A *pA=NULL; //空指针,所指向的内容不可访问存取 pA->coutHello(); pA->coutVa 阅读全文
posted @ 2011-07-08 15:09
程序员新鲜事
阅读(133)
评论(0)
推荐(0)
浙公网安备 33010602011771号