
Typedef
‘C’允许使用‘typedef’关键字定义新的数据类型名称。使用‘typedef’,我们不能创建新的数据类型,而是为已经存在的类型定义一个新的名称。
Shell本身是一个用C语言编写的程序,它是用户使用Linux的桥梁。Shell既是一种命令语言,又是一种程序设计语言。作为命令语言,它交互式地解释和执行用户输入的命令;作为程序设计语言,它定义了各种变量和参数,并提供了许多在高级语言中才具有的控制结构,包括循环和分支。它虽然不是Linux系统核心的一部分,但它调用了系统核心的大部分功能来执行程序、建立文件并以并行的方式协调各个程序的运行。因此,对于用户来说,shell是最重要的实用程序,深入了解和熟练掌握shell的特性极其使用方法,是用好Linux系统
Syntax
typedef datatype newname;
Example
的中文翻译为:示例
typedef int bhanu; int a; bhanu a; %d
- This statement tells the compiler to recognize ‘bhanu’ as another name for ‘int’.
- ‘bhanu’ is used to create another variable ‘a’ .
- ‘bhanu a ‘declares ‘a’ as a variable of type ‘int’.
Example
的中文翻译为:示例
#includemain (){ typedef int hours; hours h; //int h; clrscr (); printf("Enter hours”); scanf ("%d”, &h); printf("Minutes =%d”, h*60); printf("Seconds = %d”, h*60*60); getch (); }
输出
Enter hours =1 Minutes = 60 Seconds = 360
typedefining一个结构的示例
typedef struct employee{
int eno;
char ename[30];
float sal;
} emp;
main (){
emp e = {10, "ramu”, 5000};
clrscr();
printf("number = %d”, e.eno);
printf("name = %d”, e.ename);
printf("salary = %d”, e.sal);
getch ();
}输出
Number=10 Name=ramu Salary=5000










