Chinaunix首页 | 论坛 | 博客
  • 博客访问: 148656
  • 博文数量: 33
  • 博客积分: 1494
  • 博客等级: 上尉
  • 技术积分: 325
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-24 21:50
文章分类

全部博文(33)

文章存档

2014年(1)

2013年(1)

2012年(2)

2011年(3)

2010年(26)

我的朋友

分类: C/C++

2010-11-24 21:37:19

#include
#include
#include
using namespace std;
//用途一:为普通变量定义易于记忆的类型名
typedef int Integer;
//用途二:掩饰复合数据类型,如数组和指针
typedef char Line[20];
typedef char* ptr;
//用途三:给链表定义别名
typedef struct Student
{
char StuNo[20];
char StuName[30];
}Stu;
int main()
{
//用途一举例
Integer num = 9;
cout<<"num = "<

//用途二举例(数组)
Line str1,str2;
strcpy(str1, "hello");
strcpy(str2, "world");
cout<<"str1 + str2 = "<
//用途二举例(指针)
ptr p = str1;
for(int i = 0; p[i] != '\0'; p++)
{
cout<
}
//用途三举例
Stu student = {"1001001", "盟主仁兄"}; cout<<"学号:"<"<
return 0;
}

运行结果如下:

阅读(1226) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-11-25 11:52:45

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com