共有回帖数 0 个
-
赋值:
例如:num=1;
这行程序是一个赋值语句,赋值语句是C语言的基本操作之一。这个特殊例子的意思是把值1赋给变量num。要注意的是赋值语句的顺序是从右到左。同样,该语句也用分号结束。
printf( )函数:
printf("I am a simple.");
printf("computer.n");
printf("My favorite number is %d because it is first.n",num);
所有这些行都使用了C语言的一个标准函数:printf( )。
例如第一行,把I am a simple.传递给printf( ),这样的信息被成为参数,更完整的名称是函数的实际参数。
程序将识别两个引号之间的内容,并且把它打印到屏幕上。
2.6 多个函数
#includestdio.h
void butler();
main()
{
printf("I will summon the butler function.n");
butler();
printf("Yes,Bring me some tea and writeable CD-ROM.n");
}
void butler()
{
printf("You rang,sir?n");
}
#includestdio.h
void f(void);
main()
{
f();
f();
f();
printf("Which nobody can deny!n");
}
void f(void)
{
printf("For he's a jolly good fellow!n");
}

#includestdio.h
main()
{
int toes=10;
printf("toes = %d toes+toes = %d toes*toes = %dn",toes,toes+toes,toes*toes);
}

#includestdio.h
void f(void);
main()
{
f();
f();
f();
printf("n");
f();
f();
printf("n");
f();
printf("n");
}
void f(void)
{
printf("Smile!");
}
楼主 2015-09-14 19:15 回复
Copyright © 2010~2015 直线网 版权所有,All Rights Reserved.沪ICP备10039589号
意见反馈 |
关于直线 |
版权声明 |
会员须知