1.7问题
5.编写一条scanf语句,它需要读取两个整数,分别保存于quantity和price变量,然后再读取一个字符串,保存在一个名叫department的字符数组中。
环境:VS2010
#include "stdafx.h" int quantity,price; char department[100]; void main() { scanf("%d%d%s",&quantity,&price,department); getchar(); }
scanf函数用于格式化输入,printf函数执行格式化输出。
getchar()是为了处理VS2010环境中,dos界面一闪而过的缺陷。
注意:在scanf函数的标量参数前要加&字符。