以上楼只有 dark___templar 稍微靠谱一点。
%*作为运算符不能连着用。当然如果是
int a=4,b=2,*p=&b;
if(a%*b==0);
之类的用法那就当我没说(不过基本不会这么用- -)
----
在scanf函数族格式串中,%*可以表示跳过读取某些输入值。
援引 dark___templar 的代码,LZ可以自己试验:
#include <stdio.h>
int main()
{
int a,b;
scanf("%d%*d%d",&a,&b);
getchar();
printf("a=%d,b=%d\n",a,b);
getchar();
return 0;
}
“输入 12 3 12
这样
a b 都被赋值为12 ”
----
另外,在printf函数族中,%*里面的*表示一个从参数列表中读入的数字,用以限制长度,例如:
#include <stdio.h>
int main()
{
double a=10000.22222,b=20000.3333;
printf("a=%2.4lf,b=%16.2lf\n",a,b);
printf("a=%*.4lf,b=%*.*lf\n",2,a,16,2,b);
getchar();
return 0;
}
注意以上两个printf的效果相同。%m.n表示输出总宽度(字符数)不超过m,小数点后保留n位。
◆◆
评论读取中....
请登录后再发表评论!
◆◆
修改失败,请稍后尝试