我开始学习使用C语言编写代码,我写了以下程序:
#include<stdio.h>
int main()
{
int count = 0;
printf("Count %d.", count);
return 0;
}
然后我编译并运行程序,数据被打印出来:
Count 0.%
但是如果我将行printf("Count %d.", count);
改为printf("Count %d.\n", count);
,只需在Count %d.
后添加\n
,那么打印出的数据如下:
Count 0.
%
comes from your shell prompt. Try to run your program and redirect the output to a file. For example, if you named your programmain
:./main > test.txt
. See,%
is not in the file. Or you can reproduce the behavior with this simple commandecho -n 'toto'
- Arnaud Denoyelle